Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How can i pass parameters between two webforms???

Reply
Thread Tools

How can i pass parameters between two webforms???

 
 
Apollo0130
Guest
Posts: n/a
 
      03-11-2005
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


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      03-11-2005
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" <(E-Mail Removed)-spam.invalid> wrote in message
news:42319f33$3_3@127.0.0.1...
> 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
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com



 
Reply With Quote
 
 
 
 
=?Utf-8?B?S29zdGFkaW4gS29zdG92?=
Guest
Posts: n/a
 
      03-11-2005
Also you may use the Session object to save your string, but in your case I
think the querystring is better.

Regards,
Kostadin Kostov

"Apollo0130" wrote:

> 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
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
>

 
Reply With Quote
 
Joaquin Corchero
Guest
Posts: n/a
 
      03-11-2005
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" <(E-Mail Removed)-spam.invalid> wrote in message
news:42319f33$3_3@127.0.0.1...
> 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
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com



 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      03-11-2005
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/is...e/default.aspx

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

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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Apollo0130" <(E-Mail Removed)-spam.invalid> wrote in message
news:42319f33$3_3@127.0.0.1...
> 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
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com



 
Reply With Quote
 
Apollo0130
Guest
Posts: n/a
 
      03-14-2005
thanks for your help!!!
i have used the response.redirect method and it works very well


thanks again...


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass parameters between asp.net to asp pages rinat ASP .Net 3 02-09-2010 07:46 PM
safest way to pass parameters between pages Aussie Rules ASP .Net 3 10-09-2007 04:07 AM
difference between pass by address and pass by reference!! blufox C Programming 2 04-03-2006 02:53 PM
how to automatically pass parameters between jsp mmalaidini@gmail.com Java 7 11-16-2005 08:00 AM
How do I pass TWO parameters in Response.redirect ? Alex Nitulescu ASP .Net 2 02-02-2005 07:34 AM



Advertisments