如何防止在整個頁面中發生的PostBack中UpdatePanel的內容?如何防止從頁面的回發更新UpdatePanel的內容?
我有以下代碼:
<head runat="server">
<title></title>
<script type="text/C#" runat="server">
// I don't want it to call this event handler
// untill I update the UpdatePanel manually by UpdatePanel1.Update();
protected void TextBox2_Load(object sender, EventArgs e)
{
((TextBox)sender).Text = DateTime.Now.ToString();
}
protected void Unnamed1_Click(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox2" runat="server" OnLoad="TextBox2_Load">
</asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Unnamed1_Click" />
<asp:TextBox ID="TextBox1" runat="server" />
</div>
</form>
</body>
</html>
上面的代碼將在TextBox2中寫的,儘管它存在的UpdatePanel
內有Conditional
爲UpdateMode
。
我希望它只在我調用UpdatePanel1.Update()時更新;
任何幫助!