Cross page posting problem

V

vincenthkh

I have a simple page (testForm1a.aspx) with master page. I use
PostBackUrl on the button and send the form to second page
(testForm2.aspx). However, it seems can't get the data.
The following is the code.

(testForm1a.aspx)
--------------------------
<%@ Page Language="VB" MasterPageFile="~/masterPage1.master"
AutoEventWireup="false" CodeFile="testForm1a.aspx.vb"
Inherits="testForm1a" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentScript"
Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
PostBackUrl="~/testForm2.aspx"/>
</asp:Content>

Then I want to show the TextBox1 text on second page. However, it can
find the control.
(testForm2.aspx.vb)
------------------------------
Partial Class testForm2
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not IsNothing(Me.PreviousPage) Then
Dim textbox1 As TextBox
textbox1 = CType(Me.PreviousPage.FindControl("TextBox1"),
TextBox)
If IsNothing(textbox1) Then
Response.Write("textbox not found" & "<br>")
Else
Response.Write("textbox: " & textbox1.Text)
End If
End If
End Sub
End Class

Do anyone have suggestion?
Thanks.
Vincent
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top