Because the page, both master and content page, does not actually exist in the ASP.NET AJAX Page Method. There is no instance of the content page, therefore no reference to the master page. That is what Shared
(static
in C#) means, it is void of an instance of the class, in your case the class is the content page class.
For more information read Why do ASP.NET AJAX page methods have to be static?.
UPDATE:
There is no way to get access to the server controls, because they are part of the instance of the page, you can however get access to the Session
object, by decorating your ASP.NET AJAX Page Method, like this:
Put a value into Session
:
<WebMethod(EnableSession := True)> _
Public Shared Sub StoreSessionValue(sessionValue As String)
HttpContext.Current.Session("TheSessionValue") = sessionValue
End Sub
Retrieve a value from Session
:
<WebMethod(EnableSession := True)> _
Public Shared Function GetSessionValue() As String
Return HttpContext.Current.Session("TheSessionValue").ToString()
End Sub