Solved

POST parameters in ASP.NET

Posted on 2011-09-18
9
327 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
DevOps Toolchain Recommendations

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

 

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
 
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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 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