Solutions to post data submission restrictions under ASP

Source: Internet
Author: User

The solution is to split the data in a field that needs to send big data into smaller than the quota before submitting the form, and put the data in several hidden domains respectively, at the same time, empty the original domain and then formally submit the form. The server still uses request. Form () to read data from various den domains, and then concatenates them in order. Main Code As follows:

Note: You must specify a DIV in the HTML code of form to dynamically Insert the hidden field to it.

==== Client sample code ====

Add <Div id = divhidden> </div> to the HTML code of form, and add onsubmit = "Return fnprehandle (this)" to the form tag )", replace bigfield in the following code with the name of the field in the big database submitted in your form.
JavaScript codeCopy codeThe Code is as follows: <script language = JavaScript>
// Split the data and place it in the corresponding hidden domain.
Function fnprehandle (myform)
{
VaR icount; // The number of fields to be split.
VaR strdata; // raw data
VaR imaxchars = 50000; // considering that the Chinese character is double byte, the maximum number of characters in the domain is 50 K.
VaR ibottleneck = 2000000; // IfArticleMore than 2 m characters, prompt the user
VaR strhtml;

// Raw data
Strdata = myform. bigfield. value;

// If the article is too long, remind the user
If (strdata. length> ibottleneck)
{
If (confirm ("the article you want to publish is too long. We recommend that you split it into several parts for release. \ N if you insist on submission, note that it takes a long time to submit successfully. \ N do you insist on submitting? ") = False)
Return false;
}

Icount = parseint (strdata. Length/imaxchars) + 1;

// Hdncount records the number of subdomains in the original data domain
Strhtml = "<input type = hidden name = hdncount value =" + icount + "> ";

// Generate HTML code for each subdomain
For (VAR I = 1; I <= icount; I ++)
{
Strhtml = strhtml + "\ n" + "<input type = hidden name = hdnbigfield" + I + "> ";
}

// Dynamically Insert the HTML code of each den field in the form Div (divhidden)
Document. All. divhidden. innerhtml = strhtml;

// Assign values to each subdomain
For (VAR I = 1; I <= icount; I ++)
{
Myform. elements ["hdnbigfield" + I]. value = strdata. substring (I-1) * imaxchars, I * imaxchars );
}

// Clear the original data domain
Myform. bigfield. value = "";
}
</SCRIPT>

Server Sample Code ASP/Visual Basic CodeCopy codeThe Code is as follows: <%
Dim strdata
Dim intfieldcount
Dim I

Intfieldcount = request. Form ("hdncount ")

For I = 1 to intfieldcount
Strdata = strdata & request. Form ("hdnbigfield" & I)
Next

Response. Write strdata
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.