Click here to Skip to main content
15,920,603 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: JS Question Pin
Hakan Bulut21-Apr-13 1:44
Hakan Bulut21-Apr-13 1:44 
GeneralRe: JS Question Pin
Hakan Bulut21-Apr-13 1:51
Hakan Bulut21-Apr-13 1:51 
GeneralRe: JS Question Pin
dusty_dex21-Apr-13 2:34
dusty_dex21-Apr-13 2:34 
GeneralRe: JS Question Pin
dusty_dex21-Apr-13 5:27
dusty_dex21-Apr-13 5:27 
GeneralRe: JS Question Pin
Hakan Bulut21-Apr-13 22:52
Hakan Bulut21-Apr-13 22:52 
Questionjavascript execute usercontrol method without postback Pin
Steve Holdorf15-Apr-13 8:41
Steve Holdorf15-Apr-13 8:41 
AnswerRe: javascript execute usercontrol method without postback Pin
dusty_dex15-Apr-13 10:00
dusty_dex15-Apr-13 10:00 
AnswerRe: javascript execute usercontrol method without postback Pin
Dennis E White15-Apr-13 10:50
professionalDennis E White15-Apr-13 10:50 
server code
C#
[WebMethod]
public bool Foo()
{
    return true;
}


the in your javascript I would do something like the following (assuming you are using jQuery):

JavaScript
function callFoo(callBack) {
    $.ajax({
            type: "POST",
            url: "pageName.aspx/Foo",
            data: "{}",
            contentType:"application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                if(undefined !== callBack) {
                    callBack(msg);
                }
            }
     });
}


then to change your code I would have the following:
JavaScript
if(50 === counter) {
    callFoo(function(e) {
        // do something here
    });
}

I haven't tested this so you will have to veriy it yourself but maybe this will get you started. I am sure there are some articles on this site about calling a WebMethod from javascript.

Best of luck.
as if the facebook, twitter and message boards weren't enough - blogged

GeneralRe: javascript execute usercontrol method without postback Pin
Steve Holdorf15-Apr-13 11:38
Steve Holdorf15-Apr-13 11:38 
AnswerRe: javascript execute usercontrol method without postback Pin
Dennis E White15-Apr-13 11:43
professionalDennis E White15-Apr-13 11:43 
GeneralRe: javascript execute usercontrol method without postback Pin
Steve Holdorf15-Apr-13 12:03
Steve Holdorf15-Apr-13 12:03 
GeneralRe: javascript execute usercontrol method without postback Pin
Dennis E White15-Apr-13 12:07
professionalDennis E White15-Apr-13 12:07 
GeneralRe: javascript execute usercontrol method without postback Pin
Steve Holdorf15-Apr-13 12:15
Steve Holdorf15-Apr-13 12:15 
GeneralRe: javascript execute usercontrol method without postback Pin
Dennis E White15-Apr-13 12:19
professionalDennis E White15-Apr-13 12:19 
GeneralRe: javascript execute usercontrol method without postback Pin
Manfred Rudolf Bihy15-Apr-13 23:14
professionalManfred Rudolf Bihy15-Apr-13 23:14 
SuggestionRe: javascript execute usercontrol method without postback Pin
Steve Holdorf17-Apr-13 0:35
Steve Holdorf17-Apr-13 0:35 
QuestionCheckbox check should automatically and slowly fadeout to unchecked Pin
Member 937599314-Apr-13 7:56
Member 937599314-Apr-13 7:56 
AnswerRe: Checkbox check should automatically and slowly fadeout to unchecked Pin
Dennis E White15-Apr-13 10:29
professionalDennis E White15-Apr-13 10:29 
QuestionHow can I select a dropdown list with JQuery? Pin
AlexanderBlade13-Apr-13 23:11
AlexanderBlade13-Apr-13 23:11 
AnswerRe: How can I select a dropdown list with JQuery? Pin
Dennis E White15-Apr-13 5:15
professionalDennis E White15-Apr-13 5:15 
QuestionQuestion of a dusy_dex Pin
Hakan Bulut12-Apr-13 20:55
Hakan Bulut12-Apr-13 20:55 
AnswerRe: Question of a dusy_dex Pin
Richard MacCutchan12-Apr-13 22:15
mveRichard MacCutchan12-Apr-13 22:15 
GeneralRe: Question of a dusy_dex Pin
Hakan Bulut13-Apr-13 1:26
Hakan Bulut13-Apr-13 1:26 
GeneralRe: Question of a dusy_dex Pin
Richard MacCutchan14-Apr-13 4:32
mveRichard MacCutchan14-Apr-13 4:32 
GeneralRe: Question of a dusy_dex Pin
Hakan Bulut15-Apr-13 4:31
Hakan Bulut15-Apr-13 4:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.