Click here to Skip to main content
11,813,974 members (41,386 online)
Rate this: bad
Please Sign up or sign in to vote.
<script runat="server">
    protected void btnLogin_Click(object sender, ImageClickEventArgs e)

When I double-click on button, btnLogin_Click event is genrated in aspx page.
I want it in aspx.cs file.
Posted 5-Mar-11 20:08pm
Edited 5-Mar-11 20:16pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can use the AutoEventWireup value true or false. By default its value is set to false. We can specify the default value of the AutoEventWireup attribute in the following locations:

- The Machine.config file.
- The Web.config file.
- Individual Web Forms (.aspx files).
- Web User Controls (.ascx files)

In .Config file this attribute can be declared as:

        <pages autoEventWireup="false"

For Individual .aspx files:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" AutoEventWireup="false" Inherits="_Default" %>

I hope the above information will be helpful. If you have more concerns, please let me know.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

While creating the project, you did not check the checkbox that asks for having separate *.cs file for the designer pages.

Do it and then the event handler and Page_Load would be in the code behind.
Monjurul Habib at 6-Mar-11 4:50am
nice, but if anyone forgot to do so , then what will be the solution?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Abhinav S 265
1 Maciej Los 203
2 Palash Mondal_ 190
3 Sergey Alexandrovich Kryukov 179
0 OriginalGriff 3,877
1 KrunalRohit 2,526
2 Maciej Los 2,245
3 CPallini 2,240
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 6 Mar 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100