Click here to Skip to main content
12,764,163 members (37,108 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked
Posted 1 Mar 2012

Request.Form method while redirect another page using javascript

, 2 Mar 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
While click on hyperlink - redirect to another page and pass the Request.Form object values using javascript function
This Tips is used to download the files, by replacing the query string and use Request.Form["Name"] method while redirecting another page. It's doesn't show query string values i.e. path and file name to users. When we use query string, user able to see the path and file name from server.

In ASPX Page, while click on hyperlink it's redirect to another page and pass values to that page (like query string) using Javascript

MyPage.aspx - Hyperlink control and calling javascript function
<asp:HyperLink NavigateUrl="javascript:void(0)" onclick="simplepost('MyDownloadPage.aspx','c:\\test.xlsx');" ID="lnkBrochureDownload" runat="server"> Download our brochure </asp:HyperLink>

MyPage.aspx - Javascript Function
function simplepost(url, path) { 
document.body.innerHTML += '<form id="dynForm" action="' + url + '" method="post"><input type="hidden" name="hdnName" value="' + path + '"></form>'; document.getElementById("dynForm").submit(); }

MyDownloadPage.aspx - Read the value from MyPage.aspx using Request.Form["Name"] method like query string
if (!string.IsNullOrEmpty(Request.Form["hdnName"]))
    filePath = Request.Form["hdnName"];


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ramanujam Shankar
Web Developer Mahindra Logisoft Business Solution Limited, Chenn
India India
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 2 Mar 2012
Article Copyright 2012 by Ramanujam Shankar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid