CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Posts
    15

    Unhappy unable to use class from the server in the client

    I am trying to register server class so that I will be able to call a function in the server from the client using ajax.
    In the page load function in the server I wrote:
    Public class Cls
    Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Ajax.Utility.RegisterTypeForAjax(GetType(cls))
    End sub
    End class

    I have a function which I want to call from the client:
    <Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)> _
    Public Function IsOKToDeleteCategory(ByVal rowIndex As Integer) As Boolean
    End function

    In the client I have a java script funtion where I am trying to call to the function IsOKToDeleteCategory:
    function canDeleteCategory()
    {
    Cls. IsOKToDeleteCategory(3);
    }

    When I run the page I get an error saying that the the Cls class is undefined in the client side

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: unable to use class from the server in the client

    The client-side cannot call a server-side function, but it can call a script on the server-side with variables. That server-side script can then call that function.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured