How to call a C# function from javascript? -
i want call csharpfunction
code behind javascript. tried code below. problem whether condition true
or false
, compiler call csharpfunction
anyway! how can control that?
javascript code:
if (javascriptcondition > 0) { <%csharpfunction();%> }
c# code behind:
protected void csharpfunction() { // notification.show(); }
thanks help!
you can use web method , ajax
<script type="text/javascript"> //default.aspx function deletekartitems() { $.ajax({ type: "post", url: 'default.aspx/deleteitem', data: "", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { $("#divresult").html("success"); }, error: function (e) { $("#divresult").html("something wrong."); } }); }
[webmethod] //default.aspx.cs public static void deleteitem() { //your logic }
Comments
Post a Comment