<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script runat="server">
void Page_Load()
{
//下面定义了一个reset按钮,我想点击时也执行if内的语名(返回第一次提交状态),
//不知如何加代码?
if(IsPostBack == false )
{
label1.Text="选取";
option.Items.Add("1");
option.Items.Add("2");
option.Items.Add("3");
return;
}
label1.Text = "选取的是:" + option.SelectedItem;
option.Visible = false;
submit.Visible = false;
reset.Visible = true;
}
</script>
</head>
<body>
<form runat="server">
<asp:label id=label1 runat="server" />
<asp:dropdownlist ID="option" runat="server" />
<asp:button id="submit" text="submit" runat="server" />
<asp:button id="reset" text="reset" runat="server" visible="false" />
</form>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script runat="server">
void Page_Load()
{
//下面定义了一个reset按钮,我想点击时也执行if内的语名(返回第一次提交状态),
//不知如何加代码?
if(IsPostBack == false )
{
label1.Text="选取";
option.Items.Add("1");
option.Items.Add("2");
option.Items.Add("3");
return;
}
label1.Text = "选取的是:" + option.SelectedItem;
option.Visible = false;
submit.Visible = false;
reset.Visible = true;
}
</script>
</head>
<body>
<form runat="server">
<asp:label id=label1 runat="server" />
<asp:dropdownlist ID="option" runat="server" />
<asp:button id="submit" text="submit" runat="server" />
<asp:button id="reset" text="reset" runat="server" visible="false" />
</form>
</body>
</html>
因为LoadPage发生在handleEvent之前。那么当你在点按钮的时候,想调用的if里的语句块已经找不到了
button1_click(.....)
{
Response.Redirect(要执行的网页);
}