Click here to Skip to main content
15,670,482 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,
I have 1 html form in that have input text box for name gender and city. Now i want this data to be accessible on Page load of another aspx page after submitting the form with post method to which this Post method redirect data. How to do it?

I tried following code on aspx page pageload

string name=Request.Form["username"];

above code is not working
jkirkerx 22-Oct-14 14:06pm    
It's how you post the data to the next form, you need to rephrase your question to how to post form data to the next form, and show that code.

Yes, because Request.Form only works on the current page, where the Form has submitted the data on, once you're on the next page, you loose this Form property, you have a Request class, and you can call the Form data as an element of the Request itself.

Like this,

string name = Request["username"];
// Label1 is a Label, and it has only 'Text' method
// and not a 'text' method. Case sensitive
Label1.Text = name; 

You can run this code, and it will take the value of the username element from the Request.

Just make sure, the name of the input field is username.
Share this answer
Html page code..

<form action="HtmlToAspx.aspx" method="post">
       <div class="body bg-gray">
           <div class="form-group">
               <input type="text" name="userid" class="form-control" placeholder="User ID"/>
           <div class="form-group">
               <input type="password" name="password" class="form-control" placeholder="Password"/>
           <div class="form-group">
               <input type="checkbox" name="remember_me"/> Remember me
       <div class="footer">
           <button type="submit" class="btn bg-olive btn-block">Sign me in</button>

           <p><a href="#">I forgot my password</a></p>

           <a href="register.html" class="text-center">Register a new membership</a>

Redirect page HtmlToAspx.aspx Code..

if (!IsPostBack)
            string name = Request.Form["userid"];

And the code Working Fine..
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900