Seb*_*ins 4 javascript asp.net ajax postback
我的网站上有以下代码:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="myButton_btn" eventname="Click" />
</Triggers>
<ContentTemplate>
<script>
function pageLoad(){
window.alert("<%=Session("myVariable")%>");
}
}
</script>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="myButton_btn" Text="Prev Month" runat="server"></asp:Button>
Run Code Online (Sandbox Code Playgroud)
每次单击按钮时都会运行javascript.但是,即使我的子例程在单击按钮后更新了会话变量,我也总是得到相同的警报.换句话说,在回发后运行相同的javascript,并且它不会更新.我很肯定会话变量IS正在改变.有谁知道为什么会这样?感谢您的投入!
非常感谢!
在按钮处理程序中尝试此操作:
VB.Net
ScriptManager.RegisterStartupScript(Me.UpdatePanel, GetType(string), "alertScript", String.Format("alert('{0}');",Session("myVariable")), true)
Run Code Online (Sandbox Code Playgroud)
C#
ScriptManager.RegisterStartupScript(this.UpdatePanel, typeof(string), "alertScript", string.Format("alert('{0}');", Session["myVariable"]), true);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8040 次 |
最近记录: |