ScriptManager.RegisterStartupScript not working on ASP Button click event

巧了我就是萌 提交于 2019-12-22 09:38:29

问题


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.


回答1:


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

return;


来源:https://stackoverflow.com/questions/17484407/scriptmanager-registerstartupscript-not-working-on-asp-button-click-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!