Monday, March 26, 2012

Window.alert

Hello,

I'm trying

Response.Write(

"<script>window.alert('Impossible de supprimer cette action, cette action à déjà été effectuée ou elle doit être utilisée ...');</script>")

And i'have the Windows Internet explorer "Sys.WebForms.PageRequestManagerParserException: The Message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.write(), response filters, HttpModules, or server trace is enabled. details: error parsing near '<script>window.alert'.

Do you have an idea ? Thanks alain

Hey,

Yes, AJAX doesn't like the Response object. You could try using Page.ClientScript.RegisterClientScriptBlock() to add the script to the page. An alternative way is that if this event is triggered by a button or something, embed it in the control.


Actually, instead of using Page.ClientScript.Register*, use ScriptManager.Register*. That way the right thing happens during partial rendering.
Thanks both I used now :

ScriptManager.RegisterClientScriptBlock(

Me,Me.GetType(),"ClientScript","window.alert('Vous ne pouvez pas supprimer un client utilisez le champ Statut');",True)

and it run fine.

Big Smile Alain

No comments:

Post a Comment