How to call the code behind return type function in javascript

  1. #1

    How to call the code behind return type function in javascript

    Pls tell me how get the return type function value in javascript.below i m providing my code.

    .Js File Code
    tooltip_text = function(start, end, event) {     
          var FF = EHR.GetPhysicianName("Test");
        return FF;
    };
    
    .Cs File 
    
    [DirectMethod]
            public static string GetPhysicianName(string PHYID)
            {            
                return "Hello"+ PHYID;
            }
    pls help me as soon as possible....
    Last edited by Daniil; Mar 08, 2011 at 1:46 PM. Reason: Please use [CODE] tags
  2. #2
    It would probably go a little something like this. You would have to rewrite some stuff because you cannot directly return the result of an ajax request in a JS function. This is because it's an asynchronous call, so you'll need a callbck.

    tooltip_text = function(start, end, event) {     
           EHR.GetPhysicianName("Test", { 
                success: function(result) {
                    // do whatever you want here, the string returned from the server is inside the var 'result'. 
                ;}
           });
    };
     
    .Cs File 
     
    [DirectMethod]
            public static string GetPhysicianName(string PHYID)
            {            
                return "Hello"+ PHYID;
            }
  3. #3
    But here i want return type.how to return the result.
    EX:

    SetPhysician=function("Test")
    {
    EHR.GetPhysicianName("Test", {
    success: function(result) {
    // do whatever you want here, the string returned from the server is inside the var 'result'.
    ;}
    });
    return result;
    }

    here SetPhysician Function is returning the result(i.e is Server side function return string).pls help me
  4. #4
    Try this one

    .cs

    [DirectMethod]
    public static string GetPhysicianName(string PHYID)
       {           
             return "Hello"+ PHYID;
       }
    Js

    function getPName(data){
    
     EHR.GetPhysicianName(data,onSucc);
    
    }
    
    function onSucc(args){
    
        //to check the value
        alert(args);
    
    }
  5. #5
    Its not working.
    .CS
    [DirectMethod]
    public static string GetPhysicianName(string PHYID)
    {
    return "Hello"+ PHYID;
    }
    .JS
    scheduler.templates.tooltip_text = function(start, end, event) {
    var PhysisianName="";
    PhysisianName= DirectMethod.GetPhysicianName("Name");
    return "<b>Patient:</b> " + event.text + "<br/><b>Physician Name:</b> " + PhysisianName ;
    };


    The above code i am using to call the serverside return type function, it returns var variable(physicianName), That return value is concatinating to mainfunction( scheduler.templates.tooltip_text in .js).

    But the above code is retuning the undefined value?????
    Please do some help , is any idea!!!!!
  6. #6
    you cant call the directmethod directly, you need a callback..
  7. #7
    how to create the callback give me related example..

Similar Threads

  1. Replies: 0
    Last Post: Jan 11, 2012, 8:30 AM
  2. Call JavaScript function with CellSelection
    By bolzi89 in forum 1.x Help
    Replies: 5
    Last Post: Dec 23, 2011, 2:42 PM
  3. Replies: 8
    Last Post: Dec 23, 2011, 12:41 PM
  4. How to call the javascript function form code behind
    By harshad.jadhav in forum 1.x Help
    Replies: 3
    Last Post: Mar 29, 2011, 3:00 PM
  5. [CLOSED] Call Javascript Function
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 21, 2010, 3:58 AM

Posting Permissions