I was deeply immersed in an existing VB.NET project at work. I have never used VB.NET, so I'm struggling a bit. Does anyone know how to solve the following.
I need to pass the instance to the client side and then pass it to the shared method in order to access the instance methods when using the generic method.
The starting point is the HTML file upload control of my Contacts.aspx file:
<asp:FileUpload ID="DocUpload1" runat="server" onchange="CallMe();" />
The onchange event calls the javascript method, see below, it uses AJAX PageMethods to call the Shared method in my code for
This is the script code that is in my Contact.aspx file
<script language="javascript">
function CallMe() {
PageMethods.GetContact(0, CallSuccess, CallFailed, null);
}
function CallSuccess(res, destCtrl) {
}
function CallFailed(res, destCtrl) {
alert(res.get_message());
}
</script>
, , , " As Contacts" WebMethod, , :
Contacts.aspx.vb.
Partial Class Contacts
<System.Web.Services.WebMethod()> _
Public Shared Function GetContact(ByVal instance As Contacts) As String
Return instance.GetContactName() 'This is an instance class which I need to call.
End Function
'This is my instance class which I want to call from the Shared Class.
Public Shared Function GetContactName() As String
Return "Fred Bloggs"
End Function
End Class
- , , , , , , . , .