Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Saturday, March 24, 2012

ASP.Net 2.0 - Page Trace and Update Panel

I am just getting started with AJAX.

I have a .Net 2.0 application with page/debug trace set to true. I have a simple page listed below. When I click the button with the page/debug trace set to true, I get an error message basically saying that trace has to be false.

Does this mean that I have to always have the page/debug trace set to true for the AJAX to work?

<asp:LabelID="Label1"runat="server"Text="Label"Width="249px"></asp:Label><br/>

<br/>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<hr/>

<asp:LabelID="Label2"runat="server"Text="Label"Width="249px"></asp:Label>

<hr/>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="Button1"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

<br/>

<asp:LabelID="Label3"runat="server"Text="Label"Width="249px"></asp:Label><br/>

<br/>

<asp:ButtonID="Button1"runat="server"Text="Button"Width="233px"/></div>

Actually, I mean does page/debug trace always have to be set to FALSE for me to be able to use AJAX?

Hi,

Yes, you can't enable trace on page for asynchronous request. That's because the response must conform to a specified format, otherwise, it will fail.


Tracing doesn't work in the UpdatePanel, it'sbasically equal to using Response.Write which is also a no-no.

-Damien

Wednesday, March 21, 2012

ArgumentOutOfRangeException when calling a web service

I have a script service that is failing for some (but not all) clients. Below is the stack trace. My understanding is that Script Handler is failing to understand the request and bombs out when trying to send a json string representation of the problem. This is making it hard for me to determine what the cause of the problem is. Has anyone else seen this happen before?

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
at System.Text.StringBuilder.Append(String value, Int32 startIndex, Int32 count)
at Microsoft.Web.Script.Serialization.JavaScriptString.QuoteString(String value)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeString(String input)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal (Object o)
at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)
at Microsoft.Web.Services.RestHandler.WriteExceptionJsonString(HttpContext context, TextWriter writer, Exception ex)
at Microsoft.Web.Services.RestHandler.ProcessRequest(HttpContext context)
at Microsoft.Web.Services.ScriptHandlerFactory.HandlerWrapper.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute ()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

It seems you are having problem with serialization, you are trying to serialize which is not supoorted with default JavaScriptSeriallizer, Try FireBug forFF or Fiddler for IE to trace the JSOn string. You can also paste the code here which we can investigate.