wsyeager
Centurion
I have the following code set up for a Click event of a button for a user control:
Public Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Try
If DirectCast(ViewState.Item("PCREntry"), String) = "1" Then
Response.Write("<script>window.close();</script>")
Else
Server.Transfer("TrackingAdmin.aspx")
End If
Catch exException As ThreadAbortException
'Technically, Server.Transfer or Response.Redirect throws an exception. Catch it here and ignore it.
End Try
End Sub
I have this user control inside my web form. I want to be able to distinuish between closing the window and sending the user back to a menu screen.
When debugging and I'm inside my web form, the viewstate for "PCREntry" is indeed 1.
However, when stepping thru the Cancel event of my user control, the "PCREntry" viewstate item is Nothing.
I capture the value of "PCREntry" in viewstate in my webform as follows:
If Not IsPostBack Then
ViewState.Item("PCREntry") = DirectCast(Request.QueryString.Item("PCREntry"), String)
BindData()
End If
Why can't I access viewstate inside my user control? I thought that the user control is practically just like an "include" file where it will have access to fields on my web form...
Public Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Try
If DirectCast(ViewState.Item("PCREntry"), String) = "1" Then
Response.Write("<script>window.close();</script>")
Else
Server.Transfer("TrackingAdmin.aspx")
End If
Catch exException As ThreadAbortException
'Technically, Server.Transfer or Response.Redirect throws an exception. Catch it here and ignore it.
End Try
End Sub
I have this user control inside my web form. I want to be able to distinuish between closing the window and sending the user back to a menu screen.
When debugging and I'm inside my web form, the viewstate for "PCREntry" is indeed 1.
However, when stepping thru the Cancel event of my user control, the "PCREntry" viewstate item is Nothing.
I capture the value of "PCREntry" in viewstate in my webform as follows:
If Not IsPostBack Then
ViewState.Item("PCREntry") = DirectCast(Request.QueryString.Item("PCREntry"), String)
BindData()
End If
Why can't I access viewstate inside my user control? I thought that the user control is practically just like an "include" file where it will have access to fields on my web form...