ScriptManager.RegisterStartupScript不工作的ASP按钮单击事件 [英] ScriptManager.RegisterStartupScript not working on ASP Button click event

查看:396
本文介绍了ScriptManager.RegisterStartupScript不工作的ASP按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试

我想这一点,因为昨天的触发警报()当ASP Button_Click 。然而,当我在Page_Load中粘贴此脚本,它完美的罚款。

  ScriptManager.RegisterStartupScript(此的typeof(页),警戒,警报('填写所有字段。');,真正的);

我也低于code, ClientScript.RegisterStartupScript 这在页面加载,而不是ASP Button_Click

工程试了一下

  ClientScript.RegisterStartupScript(this.GetType(),警报,警报('填写所有字段。');,真正的);


什么,我需要做的

需要验证在客户端上的文本框present,如果这些文本框为空,应该显示一个警告对话框。


解决方案

  ScriptManager.RegisterStartupScript(此的typeof(页),警戒,警报('填写所有领域。 );,真);返回;

what I have tried

I'm trying this since yesterday, to trigger a alert() when an ASP Button_Click. However, when I paste this script in Page_Load it works perfectly fine.

ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Fill all fields.');", true);

I have also tried it with below code, ClientScript.RegisterStartupScript which works on page load and not on ASP Button_Click

ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Fill all fields.');", true);


what I need to do

Need to validate the textboxes present in client side, if these textboxes are empty it should display a alert dialog.

解决方案

ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Fill all fields.');", true);

return;

这篇关于ScriptManager.RegisterStartupScript不工作的ASP按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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