Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<script runat="server">

    protected void btnLogin_Click(object sender, ImageClickEventArgs e)
    {

    }
</script>


When I double-click on button, btnLogin_Click event is genrated in aspx page.
I want it in aspx.cs file.
Posted
Updated 5-Mar-11 20:16pm
v2

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:

XML
<configuration>
    <system.web>
        <pages autoEventWireup="false"
         />
    </system.web>
</configuration>


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.
 
Share this answer
 
v2
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.
 
Share this answer
 
Comments
Monjurul Habib 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900