Solved

POST parameters in ASP.NET

Posted on 2011-09-18
9
325 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

17 Experts available now in Live!

Get 1:1 Help Now