D
dsoltesz
I have a custom web control and i'm using viewstate for some properites. I
add the control to a page, set some properties and then try to render those
property values from viewstate to the page but I always get nothing and 0
as whats being rendered..any ideas why viewstate is not return anything
even though i'm setting the properties?
thanks
Code for Control --------------------------------
Imports System.ComponentModel
Imports System.Web.UI
Public Class EditAddSteps
Inherits System.Web.UI.UserControl
Public Sub New()
Me.EnableViewState = True
End Sub
Public Property ProjectName() As String
Get
Return CType(ViewState("ProjectName"), String)
End Get
Set(ByVal Value As String)
ViewState("ProjectName") = Value
End Set
End Property
Public Property ListID() As Integer
Get
Return CType(ViewState("ListID"), Integer)
End Get
Set(ByVal Value As Integer)
ViewState("ListID") = Value
End Set
End Property
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
End Sub
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
writer.Write("<project_name=" & Me.ProjectName & ">" & Me.ListID
& "</font>")
End Sub
End Class
----------------
code on aspx page -----------------
Protected editaddstep1 As New EditAddSteps
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 IsPostBack Then
editaddstep1.ProjectName = "PFR"
editaddstep1.ListID = 1
End If
End Sub
add the control to a page, set some properties and then try to render those
property values from viewstate to the page but I always get nothing and 0
as whats being rendered..any ideas why viewstate is not return anything
even though i'm setting the properties?
thanks
Code for Control --------------------------------
Imports System.ComponentModel
Imports System.Web.UI
Public Class EditAddSteps
Inherits System.Web.UI.UserControl
Public Sub New()
Me.EnableViewState = True
End Sub
Public Property ProjectName() As String
Get
Return CType(ViewState("ProjectName"), String)
End Get
Set(ByVal Value As String)
ViewState("ProjectName") = Value
End Set
End Property
Public Property ListID() As Integer
Get
Return CType(ViewState("ListID"), Integer)
End Get
Set(ByVal Value As Integer)
ViewState("ListID") = Value
End Set
End Property
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
End Sub
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
writer.Write("<project_name=" & Me.ProjectName & ">" & Me.ListID
& "</font>")
End Sub
End Class
----------------
code on aspx page -----------------
Protected editaddstep1 As New EditAddSteps
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 IsPostBack Then
editaddstep1.ProjectName = "PFR"
editaddstep1.ListID = 1
End If
End Sub