Problem with events in default.aspx page (ASP.net 3.5)
I am having problems with an asp.net webform that uses a master page. The problem only occurs when the page is named default.aspx. When named default.aspx if there is any code in th开发者_如何学编程e Page_Load event, other events do not fire. This also includes all code commented out I've tested OnInit and Button click events, the problem first manifested itself with button clicks not firing.
Default.aspx code
<%@ Page Title="" Language="C#" MasterPageFile="~/TWS/tws.Master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="SITMComAU.TWS.original" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="bodyPlaceholder" runat="server">
</asp:Content>
OnInit Fires: - Checked Via Break Point
public partial class original : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
int a = 1;
int b = 2;
int c = a;
}
}
OnInit Does Not Fire: - Checked Via Break Point
public partial class original : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
/*
int y = 5;
int z = y - 1;
*/
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
int a = 1;
int b = 2;
int c = a;
}
}
OnInit Does Not Fire: - Checked Via Break Point
public partial class original : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int y = 5;
int z = y - 1;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
int a = 1;
int b = 2;
int c = a;
}
}
All of the above work if the aspx, cs and designer files are renamed to anything other than default.
As for the master page. It is layout only, there is no functionality in the .cs file.
What I have tried:
- Restarting Visual Studio
- Rebooting
- Removing dll, pdb files from bin
- Voodoo
- Pulling out my hair
- Pulling out others hair
I hope some one can help!
May be the event is being fired and its just a problem with Visual Studio debugger that you are not hitting the break point. Try to write some file and see if that happens.
Try changing the codebehind namespace and/or class and see if that solves the problem. If so, it's probably due to another default.aspx page's events/controls interfering.
精彩评论