How can i pass parameters between two webforms???

A

Apollo0130

hi, i want to pass a parameter (a string) between two forms. i have a
Webform A (default.aspx) with a button and a Webform B (detail.aspx).
i want to click the button and open the webform B with the parameter
submitted from the webform A.

how can i do that?

greetz Apollo0130
 
K

Karl Seguin

How are you going from webform a to b ?

When the button in a is clicked, are you posting back and then doing a
response.redirect to be? If so you can just pass the parameters in the
querystring

Response.Redirect("detail.aspx?id=" + someId.ToString())

Alternatively, you can use Server.Transfer and store values in the the
Context.Items


karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
Apollo0130 said:
hi, i want to pass a parameter (a string) between two forms. i have a
Webform A (default.aspx) with a button and a Webform B (detail.aspx).
i want to click the button and open the webform B with the parameter
submitted from the webform A.

how can i do that?

greetz Apollo0130
 
G

Guest

Also you may use the Session object to save your string, but in your case I
think the querystring is better.

Regards,
Kostadin Kostov
 
J

Joaquin Corchero

If you don't want to use que querystring and prefer to use the request.form
what you can do is create a function that gets all the objects within the
request.form collection to create fields that you display in the form in the
page, in that way, when you send the form of the page, the values of the
previous page will be passed in the method post and you won't have to access
que querystring and the form...


<form runat="server" ....>
<--Rest of the form-->

<%=sGetFields()%>
</form>

in the code of the page

function sGetFields() as string
dim sItem as string
Dim sReturn as string
foreach sItem in Request.form
sReturn &= "<input type=""hidden"" value="""& Request.Form(sItem)
&""" name="""& sItem &""">"
next
return sReturn
end function


Apollo0130 said:
hi, i want to pass a parameter (a string) between two forms. i have a
Webform A (default.aspx) with a button and a Webform B (detail.aspx).
i want to click the button and open the webform B with the parameter
submitted from the webform A.

how can i do that?

greetz Apollo0130
 
S

Steve C. Orr [MVP, MCSD]

Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79




Apollo0130 said:
hi, i want to pass a parameter (a string) between two forms. i have a
Webform A (default.aspx) with a button and a Webform B (detail.aspx).
i want to click the button and open the webform B with the parameter
submitted from the webform A.

how can i do that?

greetz Apollo0130
 
A

Apollo0130

thanks for your help!!!
i have used the response.redirect method and it works very well :lol:


thanks again...
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top