Thursday, March 29, 2012

Pass one variable from one form to other

Hi,

I want to transfer the value of one variable ( basicaly text of a text filed) from one form to other form ...

i tried Server.Transfer("next_form.aspx") ..and then tried Request.Form("text_field") to retrieve it's content .. but doesnt work ...

i also tried Response.Redirect("next_form.aspx") ..and then tried Request.Form("text_field") to retrieve it's content .. but doesnt work ...

I think i am doing it wrong ... how can i do it .. anyone plz help :(

Thanks
imranIn your first form, put the following in your sub that gets called when you submit the form...

Response.Redirect("form2.aspx?myValue=" & myTextBox.Text)

Then in your second page...

Sub Page_Load()
TextBox2.Text = Request.QueryString("myValue")
End Sub
Hi,

When using Server.Transfer its preserveForm arguement to TRUE. This makes viewstate, event procedure available in destination form.

When using Response.Redirect, you can use querystring to pass information to the destination form like Response.Redirect("test.aspx?id=10");

HTH,
Shamir
Also see below article it could helps you

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

0 comments:

Post a Comment