Showing posts with label box. Show all posts
Showing posts with label box. Show all posts

Saturday, March 24, 2012

UpdatePanel and Exception

When throw out an Expcetion inside UpdatePanel, the error message will be display in a message box window.
How to customize the style of message in this message box? For instance, when I use \n, \r, <br> to try to seperat the message into mutiple line, it doesn't work. How to implelent it?

If throw out an exception not inside UpdatePanel, the error message will display in the page directly.
So anyway to decide the way of dispalying errormessage?

You need to specify an ErrorTemplate in your ScriptManager. There is also a server event handler that you can hook into.

See documentation here:
http://atlas.asp.net/docs/Server/Microsoft.Web.UI/ScriptManager/P_ErrorTemplate.aspx

HTH,

Perry

Wednesday, March 21, 2012

updatePanel and MessageBox(alert)

Hi,

I have a button inside an UpdatePanel,, I want to show an alert box,,, How can I do that,, ??

I tried yo write this cose in the Button Click Event

string jv ="<script>alert('Hello');</script>";this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"msg", jv,false);

but nothing happened!!

thanks,,

You have to use the ScriptManager class to register an asynchronous javascript block. To make things easier, I'd also let ASP create the script tags; if you have more than one script to register, it will put them all in one set of tags.

string jv ="alert('Hello');";ScriptManager.RegisterClientScriptBlock(myControl, myControl.GetType(),"msg", jv,true);

Do it via ScriptManager

string jv ="<script>alert('Hello');</script>";ScriptManager.RegisterClientScriptBlock(this,typeof(Page),"alert", jv,false);

YesBig Smile

I am happy,, thanks very much,,