views:

14

answers:

1

hi all, I want to make a call to a function of vb.net class from javascript. I mean I would call something which doesnot have extention as .aspx but rather .vb only. Is is possible? how?

Thanks and regards, Tanmay.

A: 

If you add

<System.Web.Services.WebMethod()>

To your function signature then you can use PageMethods to call that function from JavaScript

<System.Web.Services.WebMethod()>_
Public Shared Function DisplayDate()
    Label1.Text = DateTime.Now()
End Function

So now add a ScriptManager to your page and in the ScriptManager do this

<script language="javascript" type="text/javascript">
function ShowDate()
{
    PageMethods.DisplayDate();
}
PsychoCoder