views:

164

answers:

3

I have created a Webpage which will post as "post" method..not as "get" method.

    <html>
<head>
</head>
<body>
<FORM action="RetrieveData_Post.asp" id=form1 method=post name=form1>
 First Name:
 <br>
 <INPUT id="txtFirstName" name="txtFirstName" >
 <br>
 Last Name:
 <br>
 <INPUT id="txtLastName" name="txtLastName" >
 <br>
 <INPUT type="submit" value="Submit"> 
</FORM>
</body>
</html>

i want to retieve the values in the textboxes in the code behind of another form. Please help me.

A: 

after form post save your params in a class variable.

I don't know about asp.net but logic you used should be same we use in Ruby on Rails as follows.

say

 @first_name = params[:txtFirstName]

in your html

 <INPUT id="txtFirstName" name="txtFirstName" value="<%= @first_name %>">
Salil
if the answer specifies a language, the examples should be in the requested language. "How can I do this in Java" - "Goshh, I don't know, but you can do what I do in PHP"... Do you know what StackOverflow is meant to? :)
balexandre
+1  A: 

You can access the form fields of a request in the HttpContext:

HttpContext.Current.Request.Form

or, to cover cookies, form, query string and server variables use either the Item or Params collection of the HttpRequest instance.

(In code behind, the Page base type has a Request property to avoid going via HttpContext.)

Richard
He writes the form action should be Classic ASP (RetrieveData_Post.asp) ... why change the action if we can do everything and even redirect/transfer in the Page_Load event from what the form contains?
balexandre
still wondering if it's ASP.NET or Classic ASP :-/
balexandre
+1  A: 

Change action="RetrieveData_Post.asp" to action="RetrieveData_Post.aspx" create the aspx page and use

HttpContext.Current.Request.Form 

for retrive values.

Flatlineato