Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a c# methode from javascript/jquery and get the result
    primarykey
    data
    text
    <p>I have a dialog in an ASP.Net,c# application.This dialog has a textbox.When I choose save I want to call a function from C# who makes some verifications in the database and then to get the result in javascript/jquery.If the inserted value is true I want to close the dialog other way to remain opened,but I can't succed to close the dialog box after i receive true from c# function.Below is the code:</p> <p>ascx :</p> <pre><code> &lt;div id="popup" title="Choose Delegate"&gt; &lt;label&gt;Delegate&lt;label&gt;&lt;input type="textbox" value="" name="inputD" id=="inputD"/&gt; &lt;/div&gt; </code></pre> <p>Javascript:</p> <pre><code>$('#btnAdd').click(function(e){ $('#divPopup').slow("show"); $('#divPopup').dialog({ height:150, width:300, modal:true, buttons:{ "close":function(){$(this).dialog("close");} "save":function(){ var obj=document.getElementid("inputD"); $.ajax({ type: "POST", url: "add.aspx/check", data: "{delegate: '" + obj.Value+"'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { rez= "OK"; $(this).dialog("close"); }, failure: function () {alert("FAIL"); }}); } }); } </code></pre> <p>C#:</p> <pre><code>[WebMethode] public static Boolean check(string delegate) { ..... return true; } </code></pre> <p>C# methode returns corect value.</p> <p>I try also this :</p> <pre><code> $('#btnAdd').click(function(e){ $('#divPopup').slow("show"); $('#divPopup').dialog({ height:150, width:300, modal:true, buttons:{ "close":function(){$(this).dialog("close");} "save":function(){ var obj=document.getElementid("inputD"); var rez ; $.ajax({ type: "POST", url: "add.aspx/check", data: "{delegate: '" + obj.Value+"'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { rez= "OK"; }, failure: function () {alert("FAIL"); } }); if (rez="OK") $(this).dialog("close"); } }); </code></pre> <p>But it doesn't see the rez value in this case.</p> <p>Thanks !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload