Click here to Skip to main content
13,088,439 members (57,470 online)
Rate this:
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
Updated 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 6 Mar 2011
Copyright © CodeProject, 1999-2017
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