# Other Languages > jQuery >  Calling a Shared function from the Client side

## vuyiswamb

Good Day 

i have a shared function as called in vb.net or static function in C# that is declared like this 



```
    'Run JQuery using this 
    Public Shared Function runjQueryCode(ByVal jsCodetoRun As String, ByVal Page As Page)

        Dim requestSM As ScriptManager = ScriptManager.GetCurrent(Page)
        If requestSM IsNot Nothing AndAlso requestSM.IsInAsyncPostBack Then
            ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), Guid.NewGuid().ToString(), getjQueryCode(jsCodetoRun), True)
        Else
            Page.ClientScript.RegisterClientScriptBlock(GetType(Page), Guid.NewGuid().ToString(), getjQueryCode(jsCodetoRun), True)
        End If
    End Function
```

now the function is running the jquery from the server side, this works well now i want to call this function from the client side inside a nested table in a listview like this 



```
<div id="Div2" runat="server"  %>'  
 <a href="#" onclick=' <%# clsFunctions.runjQueryCode("$('#basic-modal-ontent').modal()", this)  %>'></a>
<img src="../../Imgs/Linkquestionare.png" border="0"/></a></div>
</td>
```

Now i have two Questions. the first one is my function accept the JQuery string and the reference to the page. Well i can do this on the server side and i am able to do this nicely , but i want to do it on the client side 

The following is content that i want to pass to the function as the first argument. /

* "$('#basic-modal-ontent').modal()"* 

and as you can see, i tried to pass * "this"*  trying to get the reference to the page. 

1) in would like to pass that string in the function as my first argument
2) i want to pass the page reference to the function as my second parameter. 

Thanks

----------


## Bill Crawley

in the second parameter 'this' in JQuery is an Object. On the server you have declared it as Page. You might need to change the server side code to accept Object.

I also believe that you might have to decorate the serverside method with 



```
[WebMethod]
Public Shared........
```

Change your onclick event to call a JQuery function in the form....



```
$("#id").click(function (event) {
            $.ajax({
            url: rootDir + Page/Method',
            type: 'POST',
            dataType: 'json',
            data: { jsCodetoRun : "$('#basic-modal-ontent').modal()", Page: this }
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                alert(data);
            },
            error: function (data, textStatus, exceptionThrown) {
                alert(data.responseText);
            }

            });
        });
```

----------

