日期:2014-05-19  浏览次数:20372 次

弹出警告框,但是不让页面刷新。
一个button类型的web控件,在它的事件函数中判断出一种情况,然后弹出警告框,但是弹出了这个警告框之后,背景页面就变白了,整个页面刷新了。

有什么办法不让它变白吗?

不要说在前台页面写js哦,有没有办法在后台实现?

------解决方案--------------------
String csname1 = "PopupScript ";
Type cstype = this.GetType();

ClientScriptManager cs = Page.ClientScript;

if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert( 'Hello World '); ";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
------解决方案--------------------
2003:RegisterStartupScript(Page)
2005:RegisterClientScriptBlock(ClientScript)