views:

230

answers:

4

I creat one WEB project, this project contain tow WEB FORM, In the first Web Form Design i have tow TextBox for Entring the date(All dataTable between this tow dates) and one Button, I want that when i press to to this Button it will load the second WEB FORM and show all the Data Table in DataGrid In this WEB FORM, So i need To call this tow TextBox value from the first WEB FORM to the second WEB FORM In Load_Page i will use this tow value in select statment. So i want to know how to call this to value from the first WEB FORM. I'am using VB.NET WEB APPLICATION.i have allrady DB in SQL .

+1  A: 

you have a lot of ways to pass values from page to another like query string, sessions, etc....

Wael Dalloul
thanks waelare you palestine?
No, I'm from syria.
Wael Dalloul
A: 

You can use querystring to get last page values to load page. Use this code

Response.Redirect("Default.aspx?value1 =" & value & "&value2" & value)

write page name as like default.aspx.

Deepak
bad way to handle it, way to easy to manipulate the data
Fredou
A: 

In the button click on the first page, you can call the second page by using Server.Transfer like this:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
   TextBox1.Text = TextBox1.Text & " Add something before continue..."
   Server.Transfer("SecondPage.aspx")
End Sub

Then you can get the textbox from the first page in the second page Page_load event:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim lastPage As Page = Context.Handler
    Dim textBox As TextBox = lastPage.FindControl("TextBox1")
End Sub

If you don't need to do anything on the button event other than posting to the next page, you can do it simpler...
Definition of the button in the ASPX markup for the first page:

<asp:Button id="Button1" PostBackUrl="SecondPage.aspx" Text="Continue" runat="Server"/>

Then you can get the textbox from the first page in the second page Page_load event:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim textBox As TextBox = PreviousPage.FindControl("TextBox1")
End Sub
awe
+1  A: 

Another way to achieve this is by using the PostBackUrl property of the button.

Refer Button..::.PostBackUrl Property for more information

ARS