Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

passing values from one web form to another

sowmyav82sowmyav82 Posts: 1Member
Hi,

Can you please tell me how I can pass values from one web form to another or how to use values entered in web form in another?

Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    : Hi,
    :
    : Can you please tell me how I can pass values from one web form to another or how to use values entered in web form in another?
    :

    You can use querystrings or sessions to pass data between pages.

    If the forms are on the same page then u can hide parts of the form in panels and switch the visibility of each panel during the form proccess. This method is convonient because controls keep their ViewState even when invisible and u can query the contents of that control.

    [code]











    [/code]

    Sample code to control the visibility of sections and to copy or simulate copying from one web form to another.

    [code]
    Protected WithEvents pnlPage1 As Panel
    Protected WithEvents pnlPage2 As Panel
    Protected WithEvents txtA As TextBox
    Protected WithEvents txtB As TextBox
    Protected WithEvents btnNext As Button
    Protected WithEvents btnFinish As Button

    Private Sub Page_Load(ByVal s As Object, e As EventArgs) _
    Handles MyBase.Load

    If Not Page.IsPostBack Then
    pnlPage1.Visible = True
    pnlPage2.Visible = False
    End If

    End Sub

    Private Sub btnNext_Click(ByVal s As Object, e As EventArgs) _
    Handles btnNext.Click

    pnlPage1.Visible = False
    pnlPage2.Visible = True

    ' Copy Contents of old vire of form into new view of form
    txtB.Text = txtA.Text
    End Sub
    [/code]

    Otherwise if you cant do it this then instead of panels, place each section on its own aspx page and then page a querystring from page one to page two.

    [code]
    Private Sub btnNext_Click(ByVal s As Object, e As EventArgs) _
    Handles btnNext.Click

    Response.ClearContent()
    Response.Redirect("NextForm.aspx?setting=valueToPass", True)
    End Sub
    [/code]

    On the next page you could do this ...

    [code]
    Private Sub Page_Load(ByVal s As Object, e As EventArgs) _
    Handles MyBase.Load

    Dim setting As String = Request.QueryString("setting")
    If Not setting Is Nothing Then
    txtB.Text = setting
    End If

    End Sub
    [/code]

    Hopefully this gives you some ideas.
Sign In or Register to comment.