This is a migrated thread and some comments may be shown as answers.

Problem posting large content with updatepanel

7 Answers 250 Views
Input
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 17 Apr 2014, 06:01 AM
Hi,

When a textbox is in an updatepanel, and trying to enter large content, the following error occurs:

System.ArgumentException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Parameter name: input
   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
   at Telerik.Web.UI.RadInputControl.LoadPostData(String postDataKey, NameValueCollection postCollection)
   at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Regard
Andreas

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Apr 2014, 07:02 AM
Hi Andreas,

Unfortunately I couldn't replicate the issue at my end. Please have a look into the sample code snippet which works fine at my end. Please provide a sample code where I can replicate the issue for further help.

ASPX:
<asp:UpdatePanel ID="PnlUpdateContent" runat="server">
    <ContentTemplate>
        <telerik:RadTextBox ID="radtxtLargeContent" runat="server">
        </telerik:RadTextBox>
    </ContentTemplate>
</asp:UpdatePanel>
<telerik:RadButton ID="radbtnChangeContent" runat="server" Text="UpdateContent" OnClick="btnChangeContent_Click">
</telerik:RadButton>

C#:
protected void btnChangeContent_Click(object sender, EventArgs e)
{
    radtxtLargeContent.Text = "Thank you for choosing Telerik UI for ASP.NET AJAX!The Telerik ASP.NET AJAX controls suite includes more than 80 versatile and performance-optimized components that help you build high-quality, professional line-of-business projects. From the leading AJAX data grid to the full-featured HTML editor used by Microsoft on sites like MSDN, Telerik UI for ASP.NET AJAX provides you with all the building blocks to maximize productivity and build richer, slicker and better-performing applications with ease.To read more about the benefits of using Telerik UI for ASP.NET AJAX, please visit the product overview page.";
}

Thanks,
Shinu.
0
Andreas
Top achievements
Rank 1
answered on 17 Apr 2014, 08:00 AM
Well, we are talking really large content here...
1000000 chars!

And it's about posting in the actual content.
Like this:
<asp:UpdatePanel ID="PnlUpdateContent" runat="server">
                <ContentTemplate>
                    <telerik:RadTextBox ID="radtxtLargeContent" runat="server" TextMode="MultiLine">
                    </telerik:RadTextBox><br />
                    <telerik:RadButton ID="radbtnChangeContent" runat="server" Text="UpdateContent">
                    </telerik:RadButton><br />
                    <asp:Label ID="lbl" runat="server"></asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>

VB:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        radtxtLargeContent.Text = New String("a"c, 1000000)
    End Sub
 
    Private Sub radbtnChangeContent_Click(sender As Object, e As EventArgs) Handles radbtnChangeContent.Click
        lbl.Text = "Updated"
    End Sub

Regards
Andreas
0
Shinu
Top achievements
Rank 2
answered on 21 Apr 2014, 06:23 AM
Hi Andreas,

This issue occurs because the JavaScriptSerializer constructor sets a hard limit to the maximum value of the maxJsonLength property. Sometimes, the maximum value is not large enough. Please try to add the following code snippet in your web.config.

<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="999999999"/>
    </webServices>
  </scripting>
</system.web.extensions>

Hope this will helps you.
Thanks,
Shinu.
0
Andreas
Top achievements
Rank 1
answered on 22 Apr 2014, 05:33 AM
Hi,

That didn't help at all.
And from what I can see in our source code, you ain't using this property anyway, but the default constructor of the JavaScriptSerializer (which has a MaxJsonLength=2097152).

Regards
Andreas
0
Angel Petrov
Telerik team
answered on 25 Apr 2014, 08:53 AM
Hi Andreas,

The problem on hand indeed seems related to the maxJsonLength. You can try increasing it by including the following settings in the web.config
<configuration>
  ...
  <system.web>
    <httpRuntime maxRequestLength="524288" executionTimeout="120000" />
  </system.web>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="2147483647"/>
      </webServices>
    </scripting>
  </system.web.extensions>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
  ...
  </system.webServer>
</configuration>
however in cases where a million characters will be transferred to the server you may again experience the same problem. I have tested the scenario and in my case I was able to place 600000 symbols in the text box. When increasing the number to 700000 again the maxJsonLength was exceeded.

Note that placing such an amount of characters in a text box is not very user friendly and dramatically increases the size of the response. That said I strongly suggest revising the requirements. If you have a specific one that demands the use of such a string please share it with us so we could suggest an alternative solution.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Andreas
Top achievements
Rank 1
answered on 25 Apr 2014, 09:23 AM
Hi,

Of course in most cases this is not very user friendly.
But our user case is the following:
Advanced users uses excel to filter large amount of data, then copies this data (or a part of it) as a raw text that will be saved in our system as a file.
This was working just fine when using a standard textbox and we had no complaint about this at all.
This is much more user friendly than if the end user had to manually first create a separate text file and then upload it...
Just copy the data and paste it is really easy for the end user in this case...

Regards
Andreas
0
Angel Petrov
Telerik team
answered on 30 Apr 2014, 08:13 AM
Hi Andreas,

The problem with using a RadTextBox in such scenario is that it stores the text twice. First in its client state and one additional time in its Text property which causes the overflow. Since you mentioned that things are working as expected with an ASP TextBox I would recommend using it instead and extending it with a RadInputManager in order to take advantage of functionality normally related to a RadInput.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Input
Asked by
Andreas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andreas
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or