: 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.