警报框不会从代码隐藏中显示 [英] alert box not displaying from the codebehind

查看:55
本文介绍了警报框不会从代码隐藏中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我试图从代码隐藏中显示警告框,我的所有控件都在我的更新面板中,当按钮单击事件发生时它应该显示警告框

代码背后:

Hi ,

Iam trying to display an alert box from the codebehind, all of my controls are inside my update panel, when the button click event occurs it should display an alert box
code behind:

ScriptManager.RegisterStartupScript(this.MyUpdatePanel,this.GetType(),Guid.NewGuid().ToString(),"alert('hello')",true);
            ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "alert('Data successfully insert into database');", true);
           ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('hello');", true);





i使用了所有这些类型的代码,如果我把这在没有更新面板的代码中工作正常,但是如果我在使用更新面板的代码中使用警报框没有显示,请帮我解决这个问题超过一天



i have used all these types of code if i put this in a code without update panel its working fine but if i use it in an code using update panel the alert box is not displaying, pls help me out got struck with this for more than a day

推荐答案

Response.Write("<script>alert('Hello!! I am Nirav Prabtani')</script>");


将JavaScript函数/代码附加到你的按钮。

Attache JavaScript function / code to your button.
btnMyButton.Attributes.Add("onclick", "javascript:altert('Hello')");




试试这个。



ScriptManager.RegisterStartupScript(btnMyButton,this.GetType (),test,alert('Hello');,true);
Hi,
try this.

ScriptManager.RegisterStartupScript(btnMyButton, this.GetType(), "test", "alert('Hello');", true);


这篇关于警报框不会从代码隐藏中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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