Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
<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 5-Mar-11 21:08pm
Edited 5-Mar-11 21:16pm
v2
Rate this: bad
good
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:
 
<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.
  Permalink  
v2
Rate this: bad
good
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.
  Permalink  
Comments
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 OriginalGriff 520
1 Maciej Los 205
2 Suvendu Shekhar Giri 159
3 Peter Leow 140
4 Kornfeld Eliyahu Peter 133
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 8,895
2 Peter Leow 5,044
3 Kornfeld Eliyahu Peter 3,333
4 Maciej Los 2,561


Advertise | Privacy | Mobile
Web01 | 2.8.150327.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