ページ全体で発生した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をに書きますがUpdateMode
ためConditional
とUpdatePanel
内に存在します。
UpdatePanel1.Update()を呼び出すときにのみ更新したいと思います。
助けてください!