Tryin2Bgood

I have this public property on my Web Service and I am accessing view state to save a variable.... But i get an error saying Name ViewState not declared....any help with this issue

Public Property Asset() As SM.Business.Asset

Get

Dim value As Object

value = ("_assetId")

If value IsNot Nothing Then

Return SM.Business.Asset.Read(CInt(value))

Else

Return Nothing

End If

End Get

Set(ByVal value As SM.Business.Asset)

ViewSate("_assetId") = value.Id

End Set

End Property

#End Region

<WebMethod(EnableSession:=True)> _

Public Function ButtonClick(ByVal newRatingValue As System.Int32) As String

Asset.AddRating(CType(newRatingValue, SM.Business.RatingScale))

_builtHtml = BuildAvgRatingDisplayAndRatingSelector(Asset)

Return _builtHtml

End Function




Re: ASMX Web Services and XML Serialization Does ViewState work when dealing with Webservices

Daniel Roth

Your code snippet shows you calling "ViewSate" instead of "ViewState". Was that just a typo

What is the exact error message you see and when do you see it

Daniel Roth






Re: ASMX Web Services and XML Serialization Does ViewState work when dealing with Webservices

Tryin2Bgood

Right when I had it as ViewState...the error was that ViewState was not declared...opps on the typo




Re: ASMX Web Services and XML Serialization Does ViewState work when dealing with Webservices

Daniel Roth

From searching on MSDN it looks like ViewState is a method on UI controls:

http://msdn2.microsoft.com/en-us/library/system.web.ui.control.viewstate.aspx

So, your web service implementation (the type with the WebMethodAttributes on it) won't have a ViewState method defined on that type unless it derives from a UI control type.

It seems a little add that your web service would have a ButtonClick method that tries to access the ViewState. Are you trying to do something like this :

Client UI app -> ButtonClick handler -> web service proxy -> web service

Your client UI app will have access to the ViewState for its various UI components. The event handlers for these components can use a web service proxy (the code that wsdl.exe or the Add Web Reference feature in VS generates) to send messages to the web service. If you want, you can pass the ViewState content to the web service as parameters, but in general a web service is a separate component and it will not have access to the ViewState.

I hope this helps.

Daniel Roth






Re: ASMX Web Services and XML Serialization Does ViewState work when dealing with Webservices

Tryin2Bgood

Yup that helped but what i was doing was trying to get my javascript to call the webservice.....and I came to the conclusion that I didnt even need that property in which was trying to access the ViewState....thanks for the help!

Happy Coding!