G
Guest
In ASP.NET 2.0, I'm using "Response.Redirect" method to pass a variable in a
URL from one page to another as such:
Protected Sub btnSubmit_Click(ByVal s as System.Object, ByVal e as
System.EventArgs) Handles btnSubmit.Click
Response.Redirect("Default2.aspx?name= " &
System.Web.HttpUtlity.URLEncode(txtName.text))
End Sub
Public ReadOnly Property TargetName( ) As String
Get
return System.Web.HttpUtility.URLDecode(txtName.Text)
End Get
End Property
______________________________________________
In Default2.aspx page, I've added an <%@ PreviousPageType
VirtualPath='~/Default.aspx' %> directive to point to the previous page.
In the "Page_Load" method, the following code was added:
Protected Sub Page_Load(ByVal s as System.Object, ByVal e as
System.EventArgs) Handles Me.Load
Dim strName As String = PreviousPage.targetName
lblGreeting.Text = "Hello " & strName & "Welcome to ASP.NET"
End Sub
_________________________________________________________
A "System.NullReferenceException: Object not set to an instance of an
object" error was thrown.
How could the "targetName" value be retrieved for displayed in the label ?
URL from one page to another as such:
Protected Sub btnSubmit_Click(ByVal s as System.Object, ByVal e as
System.EventArgs) Handles btnSubmit.Click
Response.Redirect("Default2.aspx?name= " &
System.Web.HttpUtlity.URLEncode(txtName.text))
End Sub
Public ReadOnly Property TargetName( ) As String
Get
return System.Web.HttpUtility.URLDecode(txtName.Text)
End Get
End Property
______________________________________________
In Default2.aspx page, I've added an <%@ PreviousPageType
VirtualPath='~/Default.aspx' %> directive to point to the previous page.
In the "Page_Load" method, the following code was added:
Protected Sub Page_Load(ByVal s as System.Object, ByVal e as
System.EventArgs) Handles Me.Load
Dim strName As String = PreviousPage.targetName
lblGreeting.Text = "Hello " & strName & "Welcome to ASP.NET"
End Sub
_________________________________________________________
A "System.NullReferenceException: Object not set to an instance of an
object" error was thrown.
How could the "targetName" value be retrieved for displayed in the label ?