如何显示在asp.net中警告框 [英] How to show alert box in asp.net

查看:63
本文介绍了如何显示在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆