Connecting Tech Pros Worldwide Help | Site Map

querystring length

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 14th, 2008, 04:25 PM
=?Utf-8?B?ZGlzcGxheW5hbWU=?=
Guest
 
Posts: n/a
Default querystring length

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.


  #2  
Old August 14th, 2008, 05:25 PM
Bob Barrows [MVP]
Guest
 
Posts: n/a
Default Re: querystring length

displayname wrote:
Quote:
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?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


  #3  
Old August 14th, 2008, 06:35 PM
=?Utf-8?B?ZGlzcGxheW5hbWU=?=
Guest
 
Posts: n/a
Default Re: querystring length



"Bob Barrows [MVP]" wrote:
Quote:
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.
  #4  
Old August 14th, 2008, 06:35 PM
Dave Anderson
Guest
 
Posts: n/a
Default Re: querystring length

Bob Barrows [MVP] wrote:
Quote:
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.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.