How to use Request.Form

T

TARUN

Hello All

I am getting stuck in one Problem.
I am Using C#

I have a one page called "Search.aspx" which include some TextBox,
DropDownList, ListBox.
On the Submission of this page, it navigate to "Searchresult.aspx"
Now I want to get the Value of the TextBox, DropDownList, ListBox after
submission of page.
I want to Get the Value of The Above control in "Searchresult.aspx"

I have tried this
string str = Request.Form["ControlID"];
But it not assiging anything

Or In Short
I want to access the Value of asp Controls which are encapsulted in
pervious form after submission of Form.

Please Suggest me the Code for that..

With regards
Tarun Sinha
 
J

Jacob

If you are using asp.net control you can read teh values as
Textbox.Text, DropDownList.SelectedItem.Text(or Value).
 
N

neilmcguigan

how does the first page get submitted? crosspagepostback?

if yes, you can use the PreviousPage.TextBox.Text property

otherwise, let us know
 
N

neilmcguigan

how does the first page get to the second page? crosspagepostback?

if so use

string str = ((TextBox)PreviousPage.FindControl("TextBox1")).Text;
 
L

Laurent Bugnion

Hi,
Hello All

I am getting stuck in one Problem.
I am Using C#

I have a one page called "Search.aspx" which include some TextBox,
DropDownList, ListBox.
On the Submission of this page, it navigate to "Searchresult.aspx"
Now I want to get the Value of the TextBox, DropDownList, ListBox after
submission of page.
I want to Get the Value of The Above control in "Searchresult.aspx"

I have tried this
string str = Request.Form["ControlID"];
But it not assiging anything

Or In Short
I want to access the Value of asp Controls which are encapsulted in
pervious form after submission of Form.

Please Suggest me the Code for that..

With regards
Tarun Sinha

Actually, it's pretty easy to find out. Set a breakpoint in your OnInit
event handler, and check what keys Request.Form contains. Chances are
big that you'll find something like ctl3_ControlID, which is what
happens when you place a control inside another user control. The reason
for the prefix is that the ID must be absolutely unique on the HTML page
(by HTML specification), so if your control is placed in another
control, the compiler generates a unique ID by combining the control's
ID with its parent's ID, recursively.

If for some reason you cannot use the debugger, use Fiddler to watch the
HTTP traffic.

Fortunately, the unique ID can be reached in the code: Use

Request.Form[ myControl.ClientID ];

Also, note that as others suggested, you can reach the values using the
ASP.NET controls which the framework automatically creates according to
the request's content.

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top