问题描述
嗨
我是创建网站,在按钮点击事件表单服务器端我需要显示消息/警报消息,但是更新面板内的按钮控件。
这是源代码中的代码
Hi I am create website ,in button click event form server side i need to show message/alert msg,but that button control inside of updatepanel.
This is code in source code
<asp:UpdatePanel ID="UpdatePanel6" runat="server">
<ContentTemplate>
<asp:Button ID="btnChgPass" CssClass="font12" runat="server" Text="Apply Changes" />
</ContentTemplate>
</asp:UpdatePanel>
这是在服务器中SID e,在此按钮单击事件中,我尝试使用window.alert显示HAI消息。但它从不显示消息。
This is in server side,in this button click event i try to show "HAI" message using window.alert.but it never show message.
Protected Sub btnChgPass_Click(sender As Object, e As System.EventArgs) Handles btnChgPass.Click
ClientScript.RegisterStartupScript(Me.GetType(), "ClientScript", "<script language='JavaScript'> window.alert('HAI');</script>")
End Sub
请回复我如何显示邮件表单服务器端按钮点击事件,当updatepanel里面的那个按钮控制。
注意:当我在表单加载事件中添加下面的行,即注册后退控件的按钮控件,然后它显示消息,但页面得到刷新,我不想刷新或重新加载页面,所以只有我使用updatepanel。
Pls reply me how to show message form server side button click event ,when that button inside updatepanel control.
Note:When i add below lines in form load event,i.e register post back control for button control,then it show message,but page get refresh,i don't want get refresh or reload page,so only i use updatepanel.
Dim script As ScriptManager = ScriptManager.GetCurrent(Page)
script.RegisterPostBackControl(btnChgPass)
问候
Aravind
Regards
Aravind
推荐答案
protected void Page_Load(object sender, EventArgs e)
{
string message = "Hello! Mudassar.";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("alert('");
sb.Append(message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}
Dim message As String = "alert('Please enter all values!')"
ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", message, True)
问候
Aravind
Regards
Aravind
Protected Sub btnChgPass_Click(sender As Object, e As System.EventArgs) Handles btnChgPass.Click
Dim javaScript As String = "<script language='JavaScript'> alert('Button Click client-side'); </script>"
ScriptManager.RegisterStartupScript(UpdatePanel6, UpdatePanel6.[GetType](), "alert", javaScript, True)
End Sub
这篇关于如何在asp.net表单服务器端显示消息框或警报消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!