J
jez123456
Hi Experts
I’m trying to pass a value from one webform to another using ASP.Net with vb
code behind. I have a c# example which work ok but I cannot get the vb
version working.
This is the working c# code. Basically I have WebForm1
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("anotherwebform.aspx");
}
public string Name
{
get
{
return TextBox1.Text;
}
}
public string EMail
{
get
{
return TextBox2.Text;
}
}
Then the values get passed to anotherwebform.aspx
public partial class anotherwebform : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//create instance of source web form
WebForm1 wf1;
//get reference to current handler instance
wf1 = (WebForm1)Context.Handler;
Label1.Text = wf1.Name;
Label2.Text = wf1.EMail;
}
}
My vb version has WebForm2
Partial Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer("anotherwebform2.aspx")
End Sub
Public ReadOnly Property Name() As String
Get
Return TextBox1.Text
End Get
End Property
Public ReadOnly Property EMail() As String
Get
Return TextBox2.Text
End Get
End Property
End Class
Then the values get passed to anotherwebform2.aspx
Partial Class anotherwebform2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'create instance of source web form
Dim wf1 As WebForm2
'get reference to current handler instance
wf1 = DirectCast(Context.Handler, WebForm2)
Label1.Text = wf1.Name
Label2.Text = wf1.EMail
End Sub
End Class
I get the error Type 'WebForm2' is not defined. Any ideas why. Am I doing
this correctly?
Thanks
I’m trying to pass a value from one webform to another using ASP.Net with vb
code behind. I have a c# example which work ok but I cannot get the vb
version working.
This is the working c# code. Basically I have WebForm1
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("anotherwebform.aspx");
}
public string Name
{
get
{
return TextBox1.Text;
}
}
public string EMail
{
get
{
return TextBox2.Text;
}
}
Then the values get passed to anotherwebform.aspx
public partial class anotherwebform : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//create instance of source web form
WebForm1 wf1;
//get reference to current handler instance
wf1 = (WebForm1)Context.Handler;
Label1.Text = wf1.Name;
Label2.Text = wf1.EMail;
}
}
My vb version has WebForm2
Partial Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer("anotherwebform2.aspx")
End Sub
Public ReadOnly Property Name() As String
Get
Return TextBox1.Text
End Get
End Property
Public ReadOnly Property EMail() As String
Get
Return TextBox2.Text
End Get
End Property
End Class
Then the values get passed to anotherwebform2.aspx
Partial Class anotherwebform2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'create instance of source web form
Dim wf1 As WebForm2
'get reference to current handler instance
wf1 = DirectCast(Context.Handler, WebForm2)
Label1.Text = wf1.Name
Label2.Text = wf1.EMail
End Sub
End Class
I get the error Type 'WebForm2' is not defined. Any ideas why. Am I doing
this correctly?
Thanks