如何显示在asp.net中警告框 [英] How to show alert box in asp.net
问题描述
我显示警告框在我的网页,但在那之后我的网页被打破。
I am showing alert box in my page, but after that my page is breaking down.
Response.Write("<script>alert('Selected items are removed successfully')</script>");
如何解决?
推荐答案
这不是送的JavaScript code到客户端上的ASP.NET的方式
That's not the way to send javascript code to client on ASP.NET
您可以使用 Page.ClientScript.RegisterStartupScript
You could use Page.ClientScript.RegisterStartupScript
Page.ClientScript.RegisterStartupScript(
this,
GetType(),
"ALERT",
"alert('Selected items are removed successfully')",
true);
在这种情况下,你也可以使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptblock\"相对=nofollow> Page.ClientScript.RegisterClientScriptBlock
In this case, you could also use Page.ClientScript.RegisterClientScriptBlock
Page.ClientScript.RegisterClientScriptBlock(
this,
GetType(),
"ALERT",
"alert('Selected items are removed successfully')",
true);
要理解之间的差异的RegisterStartupScript
和的RegisterClientScriptBlock
你可以点击这里
To understand differences between RegisterStartupScript
and RegisterClientScriptBlock
you could check here
<一个href=\"http://stackoverflow.com/questions/666519/difference-between-registerstartupscript-and-registerclientscriptblock\">Difference的RegisterStartupScript和的RegisterClientScriptBlock之间?
您也明白为什么他们并不总是互换。
You will also understand why they aren't always interchangeable.
这篇关于如何显示在asp.net中警告框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!