1

i'm using jquery-steps plugin and my site is on C# webforms. how to call method on click finish button. here is js

 onFinished: function (event, currentIndex) {
             var form = $(this);

             form.submit();
         }

and c# codes

protected void save(object sender, EventArgs e)
    {
        MyDB db = new MyDB ();
        MSS mus = new MSS ();
        mus.Name= name.Text;
        mus.Surname= surname.Text;
        db.MSS.Add(mus);
        db.SaveChanges();
        Response.Redirect("/Services/printOut?id="+oper.ID, false);
    }

before using jquery-steps i was just using this to call save method

<asp:Button Text="Finish" runat="server" CssClass="btn btn-info" OnClick="save" />
DSI
  • 279
  • 1
  • 6
  • 16
  • It is not clear to me what you are asking – Justin Harvey Mar 17 '14 at 13:29
  • 1
    If you are asking how do you call a C# method from Javascript, the answer is you can't. What you would need to do is create some web service and have the Javascript call the service restfully and in the service execute your code. Or a quick and dirty way would be to make a Save.aspx and on your page load execute you code above. Then in your jQuery you post your values to the Save.aspx. I highly suggest against doing that. I would build a restful WCF service or something like that and call it through the JQuery. – Bearcat9425 Mar 17 '14 at 13:30

2 Answers2

2

I had the same problem and it worked for me create a visible button = "false" is old but found no solution at all looking

<asp:Button ID="add" runat="server" Text="Button" OnClick="add_Click" Visible="false"  />

funcion javascript

 function add_() {
        document.getElementById('<%=add.ClientID%>').click();
    }

wizar-step call function

onFinished: function (event, currentIndex) {
       add_();
    }
1

I'm not entirely sure what you are asking, but if you are asking how to call a code-behind method using jQuery, check out page methods.

Below is a good tutorial on how to do them:

http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/