|
| Error in validationRequest dont captured by OnPageError in ScriptManager |
 |
Wed, 27 Sep 2006 14:21:02 +000 |
Hi,
I dont know if this is correct or not.
But, watch this code:
<atlas:ScriptManagerID="ScriptManager1"runat="server"Enab
lePartialRendering="true"OnPageError="ScriptManager_error"&g
t;
</atlas:ScriptManager>
<formid="form1"runat="server">
<div>
<atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:TextBoxID="TextBox1"runat="server"OnTextChanged=&quo
t;TextBox1_TextChanged"></asp:TextBox>
</ContentTemplate>
</atlas:UpdatePanel>
</div>
</form>
Running this sample, if i write in the TextBox the text "<asd>"
i got a alert with "Unknow Error". Why this error isnt captured by
OnPageError event ?
tks
cya
|
| Post Reply
|
| Re: Error in validationRequest dont captured by OnPageError in ScriptManager |
 |
Wed, 27 Sep 2006 14:56:08 +000 |
hello.
hum...are you sure your method isn't being called? if i recall correctly, the
exception is allways propagated to the client where you'll get a msgbox with
something like unkown error or exception. what you can do is define a template
that will presented to the user instead of default error msg (look for the
errortemplate prop of the scriptmanager class).
|
| Post Reply
|
| Re: Error in validationRequest dont captured by OnPageError in ScriptManager |
 |
Wed, 27 Sep 2006 18:10:09 +000 |
hi,
Try this sample
In aspx:
<atlas:ScriptManagerID="ScriptManager1"runat="server"Enab
lePartialRendering="true"OnPageError="ScriptManager_error"&g
t;
</atlas:ScriptManager>
<formid="form1"runat="server">
<div>
<atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextB
ox>
<asp:ButtonID="Button1"runat="server"Text="Button&qu
ot;OnClick="Button1_Click"/>
</ContentTemplate>
</atlas:UpdatePanel>
</div>
</form>
In .cs:
protectedvoid Button1_Click(object sender, EventArgs e)
{
if (this.TextBox1.Text == "a")
{
Int32.Parse(this.TextBox1.Text);
}else {
this.Button1.Text = this.TextBox1.Text;
}
}
protectedvoid ScriptManager_error(object sender,
Microsoft.Web.UI.PageErrorEventArgs e)
{
this.Response.Write("<script>alert('" + e.Error.ToString() +
"')</script>");
}
When you write:
a = The code pass in the ScriptManager_error and i got my alert with my error
<asd> ( or another thing that with tags ) = You got a alert Unknow Error
and the code dont pass in the ScriptManager_error
some text diferent from "a" = your button get the text in the textbox
Now i ask. Its normal the OnPageError dont catch the error in validationRequest
?
tks
cya
|
| Post Reply
|
| Re: Error in validationRequest dont captured by OnPageError in ScriptManager |
 |
Wed, 27 Sep 2006 18:50:05 +000 |
hello.
ah, yes! nice one...well, i only understood what was going on after seeing the
stack trace :)
well, you've just found a bug. normally, the scriptmanager will handle the
exceptions generated by the page; the problem is that the scriptmanager class
only performs the wire up of the event and this exception is generated before
that event :(
the unknown error you'te getting is because that event is being fired and no one
is handling it. because of that, the client portion of atlas is receiving the
classic html that you see when you get that exception (since it only understands
the xml message, it can't really do anything about it!).
so, what can you do to solve this? i see 2 options:
1. disactivate request validation
2. if that's not possible, then you can try to do the follwoing (i haven't
tested this, but...):
2.1 handle the error event by introducing a method on the page that overrides
the on error method. in that method, see if the init has already happened; if it
hasn't, then save the exception in a page variable.
2.2 during the load event (or other event that happens after the init event)
check that variable; if it's different from null, rethrow the exception. this
should be enough for making scriptmanager handle the event
i must say that 2 should be theoption to follow and that i haven't tested 2 :D
|
| Post Reply
|
| Re: Error in validationRequest dont captured by OnPageError in ScriptManager |
 |
Wed, 27 Sep 2006 19:46:37 +000 |
Hi,
About the 2 options:
1. Works .... but i dont have the validadionRequest and i need to use the
Server.HtmlEncode in the methods
2. I try it :D . Overriding the OnError in the Page i can get the error and see
if it occurs before ou after the Init. But, i have the "Unknow Error"
after pass in OnError and the event Page_Load is not fired.
This issue will be considered a bug ?
tks
cya
|
| Post Reply
|
|
|
|
|
|
|
|
|
|