G
Guest
Hi,
I have two froms (form1 and form2). I want to be able to pass values from
form 1 to form2 and be able to use those values leter in form2. This is my
code for form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer("form2.aspx", True)
End Sub
Public ReadOnly Property Property1() As String
Get
Return DropDownList1.SelectedItem.Text
End Get
End Property
This is my code for form2
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
sourcepage = CType(Context.Handler, transsend)
TextBox1.Text = sourcepage.Property1
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
sourcepage = CType(Context.Handler, transsend)
TextBox2.Text = sourcepage.Property1
End Sub
The form load works perfect on form2 but when I click the button1 on form2 I
get the error
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 45: Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Line 46:
Line 47: sourcepage = CType(Context.Handler, transsend)
Line 48:
Line 49: TextBox2.Text = sourcepage.Property1
Any ideas?
I have two froms (form1 and form2). I want to be able to pass values from
form 1 to form2 and be able to use those values leter in form2. This is my
code for form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer("form2.aspx", True)
End Sub
Public ReadOnly Property Property1() As String
Get
Return DropDownList1.SelectedItem.Text
End Get
End Property
This is my code for form2
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
sourcepage = CType(Context.Handler, transsend)
TextBox1.Text = sourcepage.Property1
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
sourcepage = CType(Context.Handler, transsend)
TextBox2.Text = sourcepage.Property1
End Sub
The form load works perfect on form2 but when I click the button1 on form2 I
get the error
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 45: Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Line 46:
Line 47: sourcepage = CType(Context.Handler, transsend)
Line 48:
Line 49: TextBox2.Text = sourcepage.Property1
Any ideas?