aspx的一个重要特点是postBack
<form name="Form1" method="post" action="myClient.aspx" id="Form1">
form1把数据post给了self;viewState里面用来存储控件的状态数值;
以使当form1发送回,时间填控件的状态;我的理解发送post请求的时间,
http1.1 post login.aspx
localhost
value="***********";
当postBack时间
<%@ Page Language="C#" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Submit.Attributes.Add("onclick", "NoPostBack('secondform.aspx');");
}
</script>
<html>
<head>
<title>Form Post to another ASP.Net Page</title>
<script language="javascript">
<!--
function NoPostBack(sNewFormAction)
{
document.forms[0].action = sNewFormAction;
document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
}
-->
</script>
</head>
<body>
<form runat="server">
<div id="Content" name="content">
<asp:textbox id="SomeText" runat="server"></asp:textbox>
<asp:button id="Submit" runat="server" text="Submit Form"></asp:button>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Result.Text =Request.Form["SomeText"].ToString();
}
</script>
<html>
<head>
<title>Post results</title>
</head>
<body>
<form runat="server">
<b>You typed:</b> <asp:Label id="Result" runat="server">Label</asp:Label>
</form>
</body>
</html>