ScriptManager.RegisterStartupScript not working on ASP button click event

what i tried

I try to do this from yesterday , to trigger a warning () when ASP Button_Click . However, when I embed this script in Page_Load, it works fine.

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

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

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

What should I do

You must verify the correctness of the text fields on the client side; if these text fields are empty, it should display a warning dialog box.

+3
source share
1 answer
ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Fill all fields.');", true);

return;
+3

Source: https://habr.com/ru/post/1569687/


All Articles