Solved

POST parameters in ASP.NET

Posted on 2011-09-18
9
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

615 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