ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
passing values from one web form to another Posted by sowmyav82 on 18 Oct 2003 at 8:01 PM
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?
Report
Re: passing values from one web form to another Posted by iwilld0it on 20 Oct 2003 at 7:33 AM
: 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.

<form runat="server">
<asp:panel id="pnlPage1" visible="False" runat="server">
   <asp:textbox id="txtA" runat="server" />
   <asp:Button id="btnNext" text="Next" runat="server" />
</asp:panel>

<asp:panel id="pnlPage2" visible="False" runat="server">
   <asp:textbox id="txtB" runat="server" />
   <asp:Button id="btnFinish" text="Finish" runat="server" />
</asp:panel>
</form>


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

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


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.

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


On the next page you could do this ...

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


Hopefully this gives you some ideas.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.