如何发出警报信息 [英] how to give alert message
本文介绍了如何发出警报信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我想如何在asp.net(c#)代码中为添加记录提供警告消息
它应该询问是否添加或者不是那样的
hi
I want how to give alert message in asp.net (c#) code for the adding a records
it should ask whether it is add or not like that
推荐答案
如果您在页面上使用更新面板,请使用以下代码。
if you are using update panel on the page use the below code.
string script = " <script type=\"text/javascript\"> alert('" + message + "') </script> ";
ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", script, false);
如果页面不包含ajax更新面板,你可以使用它。
if page doesn't contains ajax update panel, u can use this.
this.Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", script);
只需在记录插入代码后添加以下内容
Just add the below after the record insertion code
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Message", "alert('Successfully Added')", true);
考虑来自OP的评论包含显示确认框的代码
将此添加到您的pageload事件
Considering the Comment from OP included code to show Confirmation Box
Add this to your pageload event
btnAdd.Attributes.Add("onclick",
"return confirm('Do you want to Add?');");
希望这可以帮助你...
Hope this helps you...
你可以使用: -
string msg =这是我的消息;
Response.Write(alert(+ msg +));
希望,这会对你有帮助....
You can use:-
string msg="This is my msg";
Response.Write("alert("+msg+")");
Hope, this will helps you....
这篇关于如何发出警报信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文