Jquery – How to call a client-side method from an asp.net method


I have the following javascript:

<script type="text/javascript">
    function showjQueryDialog() {

    $(document).ready(function() {
           autoOpen: false,
           modal: true,
           buttons: { "Renew Membership": function() { $(this).dialog("close"); } }

I have an asp:Button on the page which logs the user it. This is the sample of what I want to occur when the button is clicked on the server-side:

protected void LoginButton_OnClick(object sender, EventArgs e)
    UserProfile profile = UserProfile.GetUserProfile(txtUserName.Text);

    TimeSpan ts = profile.Expiration.Subtract(DateTime.Now);

    if(ts.Days <= 30)
      //call showJQueryDialog() to open the dialog box
      Page.ClientScript.RegisterStartupScript(typeof(Login2), "showjquery",   
      "showJQueryDialog();", true);
     //log the user in as normal.


Also is how would I attach a method such as the following to the Renew Button on the Dialog

public void Renew()

Best Solution

As calling client side function is not possible I would suggest to emit in javascript the information required for the decision and make everything happen on the client side.

Alternatively you can do need a page reload, as suggested from previous commenter.