且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ScriptManager.RegisterStartupScript不工作的ASP按钮单击事件

更新时间:2023-12-05 23:16:22

  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;