Monday, March 26, 2012

How do I display a simple message box using Ajax?

I'm doing a check to make sure that at least one out of 5 search text fields are entered. If none are entered, I want to display a message saying so. How do I do this?

The following works if I do not use Ajax:

DisplayClientError("My message to be displayed here");

privatevoid DisplayClientError(string errorDesc)

{

string script ="<script language=\"javascript\">alert('" + errorDesc +"');</script>";ClientScript.RegisterStartupScript(typeof(Page),"UserSecurity", script);

}

But this doesn't show up in Ajax version.

Thanks.

Use ScriptManager.RegisterStartupScript() instead.


Try this

privatevoid DisplayClientError(string errorDesc)

{

string script ="alert('" + errorDesc +"');";

ScriptManager.RegisterStartupScript(this,typeof(Page),"UserSecurity", script,true);

}


Oh !!!! I see what's happening now. Thanks a lot.


thx for that !!Smile

No comments:

Post a Comment