Solved

POST parameters in ASP.NET

Posted on 2011-09-18
9
326 Views
Last Modified: 2012-05-12
I want to redirect to another ASP.NET (C#) page and at the same time, pass POST parameters to it.
On the second page, I want to retrieve these parameters.

If possible, please provide some sample code. Thanks!
0
Comment
Question by:dshrenik
9 Comments
 
LVL 14

Expert Comment

by:nishant joshi
ID: 36557094
0
 

Author Comment

by:dshrenik
ID: 36557098
The link is broken.
0
 
LVL 14

Accepted Solution

by:
nishant joshi earned 125 total points
ID: 36557100
http://w3schools.com/aspnet/aspnet_forms.asp


there is a problem with link tag in EE.
0
 

Author Comment

by:dshrenik
ID: 36557111
I want to do it this way:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

I am not sure how I can POST parameters, and also redirect to the url. The webpage represented by "url" must then retrieve the POST parameters.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 14

Expert Comment

by:nishant joshi
ID: 36557129
0
 
LVL 3

Assisted Solution

by:ExpertLogin_890
ExpertLogin_890 earned 125 total points
ID: 36559198
you can pass the post parameter by using the form collection with Request object add the hidden fields for parameter those you want to pass through the pages those you dont want to view by others
your form having fields like

ID: <input name="ID">
 Name : <input name="name">
Addres:  <input name="address">

etc.
and submit the form using form.submit method using post method
you can retrieves the values in code behing page

Request.Form("firstname")

or in htmlcode file

<%=Request.Form%>  





0
 
LVL 7

Assisted Solution

by:gopaltayde
gopaltayde earned 125 total points
ID: 36560046
here is the link for cross page postback

http://msdn.microsoft.com/en-us/library/ms178139.aspx
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 125 total points
ID: 36560130
you can try with following code

void Page_Load(object sender, EventArgs e)
{
    System.Text.StringBuilder displayValues = 
        new System.Text.StringBuilder();
    System.Collections.Specialized.NameValueCollection 
        postedValues = Request.Form;
    String nextKey;
    for(int i = 0; i < postedValues.AllKeys.Length; i++)
    {
        nextKey = postedValues.AllKeys[i];
        if(nextKey.Substring(0, 2) != "__")
        {
            displayValues.Append("<br>");
            displayValues.Append(nextKey);
            displayValues.Append(" = ");
            displayValues.Append(postedValues[i]);
        }
    }
   Label1.Text = displayValues.ToString();
}

Open in new window


For more ways check following link
http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx#Y2052
0
 

Author Comment

by:dshrenik
ID: 36564070
The problem is that I need to construct the POST parameters with C# code. They're not values of form elements.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Read about why website design really matters in today's demanding market.
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now