4

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.

2
  • are you using update panel? Commented Jul 5, 2013 at 11:00
  • no i'm not using update panel.. Commented Jul 5, 2013 at 12:54

1 Answer 1

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

return;
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't do a thing for me. Why would returning from an already-returning void method do anything?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.