一个非常简单又很变态的问题!
在IE地址栏中直接敲入一个如:
http://localhost:2556/webUI/addnotice.aspx时,
addnotice.aspx.cs文件中的Page_Load事件没有运行,大家帮我看看这是怎么回事?
我的本意是必须已经登陆过了才能进入addnotice.aspx.
addnotice.aspx中代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="addnotice.aspx.cs" Inherits="addnotice" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>添加通知</title>
<link href="css/zcr_css.css" type="text/css" rel="stylesheet"/>
<script language="javascript" type="text/javascript">
function check()
{
if(document.getElementById("txttitle").value=="")
{
alert("标题不能为空!");
document.getElementById("txttitle").focus();
return false;
}
if(document.getElementById("txtcontent").value=="")
{
alert("内容不能为空!");
document.getElementById("txtcontent").focus();
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#F4F9FF">
<form id="form1" runat="server" method="get">
<div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="#DBEBF9" class="zcr_login5" style="padding-left: 10px;" colspan="2"><strong>当前位置:添加新通知</strong></td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%">
标题:
</td>
<td class="zcr_login3" align="left">
<asp:TextBox ID="txttitle" runat="server" Text="" Width="500px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%">
内容:
</td>
<td class="zcr_login3" align="left">
<asp:TextBox ID="txtcontent" runat="server" TextMode="multiLine" Width="500px" Height="400px" Text=""></asp:TextBox>
</td>
</tr>
<tr>
<td class="zcr_login4" align="right" width="10%" style="height: 22px">
附件:
</td>
<td class="zcr_login3" align="left" style="height: 22px">
<asp:FileUpload ID="fileup1" runat="server" />
<span class="zcr_login4" ><strong>注:上传附件只能是doc,xls文件格式</strong></span>
</td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%">
</td>
<td class="zcr_login3" align="left">
<asp:FileUpload ID="fileup2" runat="server" />
</td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%">
</td>
<td class="zcr_login3" align="left">
<asp:FileUpload ID="fileup3" runat="server" />
</td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%" style="height: 22px">
</td>
<td class="zcr_login3" align="left" style="height: 22px">
<asp:FileUpload ID="fileup4" runat="server" />
</td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%">
</td>
<td class="zcr_login3" align="left">
<asp:FileUpload ID="fileup5" runat="server" />
</td>
</tr>
<tr>
<td class="zcr_login3" align="right" width="10%">
</td>
<td class="zcr_login3" align="left">
<asp:Button ID="btnsubmit" runat="server" Text="提 交" OnClick="btnsubmit_Click" OnClientClick="return check();" />
<asp:Button ID="btnclear" runat="server" Text="请 空" OnClick="btnclear_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
addnotice.aspx.cs中部分代码:
public partial class addnotice : System.Web.UI.Page
{
private PMaddnotice Model = new PMaddnotice();
/// <summary>
/// 窗体初始化
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Model.init();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Comsession.loginInfo == null)
{
//JScript.ShowMessage(Page, "您还没有登录,请先登录!");
JScript.Redirect("login.aspx");
return;
}
}
}
}