Custom Server Control

K

Kirk Graves

I am in the process of developing a WebControl. Everything works fine,
except that viewstate does not seem to be working. can anyone give me some
clue

Thank you in advance.
here is the code that is causing me trouble

-------------------------------------
Protected Overrides Function SaveViewState() As Object

Me.ViewState.Add("Month", ddlYear.ClientID)

Return MyBase.SaveViewState()
' at this point the value is showing correctly when queried in the
immediate window

End Function

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim MonthID As String
Dim YearID As String

MyBase.LoadViewState(savedState)

Month = Convert.ToDateTime(viewstate("Month"))

' Month now is nothing ????
End Sub
 
N

Natty Gur

Hi,

You should return the data that you want to preserve in view state. take
a look in the following MSDN articles :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfsystemwebuicontrolclasssaveviewstatetopic.asp

and

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfsystemwebuicontrolclassloadviewstatetopic.asp

Load/Save viewstate are called by the page for every control when the
page save \ load viewstate from persist medium. The data that controls
return preserve in viewstate control using Losformatter class or extract
from viewstate and send to relevant controls.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top