当前位置: 首页 > 编程语言 > C#

如何在asp.net中显示警告框Share

时间:2023-04-10 18:42:24 C#

如何在asp.net中显示警告框我有一个带有提交按钮的注册页面。我想在“用户单击提交按钮”之后显示一个警告框,之后“用户输入的数据将被插入到数据库中”。inti=obj.IU_SubscriberMaster(0,txtFirstname.Text,txtLastname.Text,txtEmail.Text,txtPassword.Text);如果(i>0){CallErrorTrap("errormsg");}这就是我要显示警报的地方。我使用了功能警报(str){returnfalse;}而不是通过创建函数errortrappublicvoidErrorTrap(stringstr){if(!ClientScript.IsStartupScriptRegistered("alert")){Page.ClientScript.RegisterStartupScript(this.GetType(),"alert","alerts('"+str+"');",真);但它不起作用任何人都可以帮忙吗?常规页面publicvoidErrorTrap(stringstr){Page.ClientScript.RegisterStartupScript(this.GetType(),"alert"+UniqueID,"alert('"+str+"');",true);}如果Ajax页面使用了ajax,则需要使用ScriptManager。publicvoidErrorTrap(stringstr){ScriptManager.RegisterStartupScript(Page,Page.GetType(),"alert"+UniqueID,"alert('"+str+"');",true);}警报:Page.ClientScript。RegisterStartupScript(this.GetType(),"alert","alerts('"+str+"');",true);需要警报:Page.ClientScript.RegisterStartupScript(this.GetType(),"alert","alert('"+str+"');",true);你是说javascript是“alerts(”+str+“');”而不是“警报(”+str+“');”?警报应该警报。如果您使用的是ajax,最好使用ScriptManager。以上是C#学习教程:如何在asp.net中显示警告框。如果对大家有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: