querystring length


D

displayname

I have an ASP page with a button and other things.
When the button is clicked, it executes a javascript function which does:

document.Form1.method = 'post';
document.Form1.action = "AnotherASPpage.asp?p1=" + allFields1 + "&p2=" +
allFields2 + "&p3=" + bVar;
document.Form1.submit();

allFields1 represents all the fields in category 1 that user has selected.
The fields are delimited by comma.
allFields2 represents all the fields in category 2 that user has selected.
The fields are delimited by comma.

The AnotherASPpage.asp is supposed to display the result in Excel spreadsheet.

I test it by selecting 15 fields in category 1 and it pops up a File
Download small window asking if I want to Open, Save, or Cancel the Excel
file. It shows an Excel name like abc.xls in the Name: section in that small
window. I can Save the file successfully.

But, when I select 16 fields in category 1, pops up a File Download small
window asking if I want to Open, Save, or Cancel the Excel file. But, it
doesn't show an Excel name like abc.xls in the Name: section in that small
window. It shows ..., id1%20AS%20... When I click Save, it gives error about
IE can't download ...&p3=...

It looks like the limit of the querystring in the URL is too long. But with
POST method the limit is huge and I'm no where near that limit.

I am thinking about using hidden variables to pass data from one page to
another but I can't because onclick of a button page1 invokes a javascript
function which submits AnotherASPpage.asp and thus doesn't know about the
hidden variables from page1.

Can someone please help? Thanks.
 
Ad

Advertisements

B

Bob Barrows [MVP]

displayname said:
I have an ASP page with a button and other things.
When the button is clicked, it executes a javascript function which
does:

document.Form1.method = 'post';
document.Form1.action = "AnotherASPpage.asp?p1=" + allFields1 +
"&p2=" + allFields2 + "&p3=" + bVar;
document.Form1.submit();

allFields1 represents all the fields in category 1 that user has
selected. The fields are delimited by comma.
allFields2 represents all the fields in category 2 that user has
selected. The fields are delimited by comma.

The AnotherASPpage.asp is supposed to display the result in Excel
spreadsheet.

I test it by selecting 15 fields in category 1 and it pops up a File
Download small window asking if I want to Open, Save, or Cancel the
Excel file. It shows an Excel name like abc.xls in the Name: section
in that small window. I can Save the file successfully.

But, when I select 16 fields in category 1, pops up a File Download
small window asking if I want to Open, Save, or Cancel the Excel
file. But, it doesn't show an Excel name like abc.xls in the Name:
section in that small window. It shows ..., id1%20AS%20... When I
click Save, it gives error about IE can't download ...&p3=...

It looks like the limit of the querystring in the URL is too long.
But with POST method the limit is huge and I'm no where near that
limit.

I am thinking about using hidden variables to pass data from one page
to another but I can't because onclick of a button page1 invokes a
javascript function which submits AnotherASPpage.asp and thus doesn't
know about the hidden variables from page1.
I don't understand the problem. In the form's onsubmit event, populate the
hidden elements with the required values. Forget about the querystring.

What's the problem?
 
D

displayname

Bob Barrows said:
I don't understand the problem. In the form's onsubmit event, populate the
hidden elements with the required values. Forget about the querystring.

What's the problem?

After user selects all the fields, there's need to have a way to tell the
program to query the data and display the result in Excel. The button is a
way to let the user do that.
Here's the sequence of events:
1) page1.asp is rendered
2) user selects some fields from page1 and click the button
3) can page1.asp sets some hidden variables to indicate which fields the
user has just selected at this point?
4) page1.asp redirects to AnotherASPpage which needs to know which fields
the user selected.
5) AnotherASPpage.asp queries the database for those selected fields and
displays the result in Excel.
6) user still sees page1.asp and doesn't see AnotherASPpage.asp at all.
 
Ad

Advertisements

D

Dave Anderson

Bob said:
I don't understand the problem. In the form's onsubmit event,
populate the hidden elements with the required values. Forget
about the querystring.
What's the problem?

For one thing, hidden inputs can very much impact the length of the
querystring. The OP's red herring is setting the form method to "post",
while littering the action with name-value pairs. His script is, in effect,
reading the querystring.

The problem with using POST and returning an ASP document with ContentType =
"application/vnd.ms-excel" (or
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" if Excel
2007) is that Internet Explorer handles the response, determines that the
ContentType requires an external application, then hands over the URL (not
the response stream) to Excel. At this point, Excel knows nothing about the
original POST, and submits a new request with the querystring only. This can
be confirmed by reading the IIS logs.

Gecko Browsers have no such problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top