How can i pass parameters between two webforms???

Discussion in 'ASP .Net' started by Apollo0130, Mar 11, 2005.

  1. Apollo0130

    Apollo0130 Guest

    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
     
    Apollo0130, Mar 11, 2005
    #1
    1. Advertising

  2. Apollo0130

    Karl Seguin Guest

    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" <-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
     
    Karl Seguin, Mar 11, 2005
    #2
    1. Advertising

  3. 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
    >
     
    =?Utf-8?B?S29zdGFkaW4gS29zdG92?=, Mar 11, 2005
    #3
  4. 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" <-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
     
    Joaquin Corchero, Mar 11, 2005
    #4
  5. 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

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


    "Apollo0130" <-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
     
    Steve C. Orr [MVP, MCSD], Mar 11, 2005
    #5
  6. Apollo0130

    Apollo0130 Guest

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


    thanks again...


    Posted Via Usenet.com Premium Usenet Newsgroup Services
    ----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    ----------------------------------------------------------
    http://www.usenet.com
     
    Apollo0130, Mar 14, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c3Jpa2lydGk=?=

    unable to pass data b/w 2 webforms

    =?Utf-8?B?c3Jpa2lydGk=?=, May 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    420
    Ashish M Bhonkiya
    May 20, 2004
  2. Alex Nitulescu
    Replies:
    2
    Views:
    39,834
    Alex Nitulescu
    Feb 2, 2005
  3. Replies:
    7
    Views:
    19,173
  4. blufox
    Replies:
    2
    Views:
    582
  5. Aitham alama

    Passing values between two webforms

    Aitham alama, Jul 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    128
    Ken Cox [Microsoft MVP]
    Jul 10, 2004
Loading...

Share This Page