function is not calling Directmethod

  1. #1

    function is not calling Directmethod

    In my code I am not able to Call directMethod from the javascript function
    Below is my code
     protected void Submit(object sender, DirectEventArgs e)
            {
                id = Convert.ToInt32(e.ExtraParams["Id"]);
                objTemp.ProjectID = id;
    
                if (e.ExtraParams["command"] == "Delete")
                {
                    X.Msg.Confirm("Confirm", "Are you sure you want to do that?", new JFunction { Fn = "showResult" }).Show();
                    
                    
                        //objTemp.Delete();
                        //BindGrid();
                        //ProjectStore.DataBind();
                    
                }
                else
                {
    //For edit
    }
    Function
     var showResult= function (btn) 
            {
               
                if(btn=='yes')
                {
                     //Ext.Msg.notify("Button Click", "You clicked the " + btn + " button");
                      Ext.net.DirectMethods.CommitDelete();   
                       
                }
            };
    Directmethod
     [DirectMethod()]
            public void CommitDelete()
            {
                //objTemp.ProjectID = id;
                //this.Label1.Text = DateTime.Now.ToLongTimeString();
                objTemp.Delete();
                BindGrid();
                ProjectStore.DataBind();
            }
    Now javascript function is not calling this Directmethod
    Last edited by Vaishali; Jan 03, 2013 at 11:21 AM.
  2. #2
    Please see the following link:-

    https://examples2.ext.net/#/Events/D...hods/Overview/

    Hope this helps you....
  3. #3
    Hi Vaishali,

    you have to define DirectMethodNamespace.

    For eg.

    <ext:ResourceManager runat="server" DirectMethodNamespace="Test" />

    Also you have to modify the following:-

    var showResult= function (btn) 
           {
               
               if(btn=='yes')
               {
                    //Ext.Msg.notify("Button Click", "You clicked the " + btn + " button");
                     Ext.net.DirectMethods.CommitDelete();   Replace this      Test.CommitDelete();
                       
               }
           };
    I think it will work....

    Thanks
  4. #4
    Ext.net.DirectMethods.CommitDelete(); Replace with Test.CommitDelete();

    if you are using
    <ext:ResourceManager runat="server" DirectMethodNamespace="Test" />
    Thanks

Similar Threads

  1. Replies: 7
    Last Post: Oct 21, 2014, 6:22 AM
  2. [CLOSED] calling directmethod syncronously
    By kemalyigit in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 24, 2012, 12:49 PM
  3. [CLOSED] DesktopShortcut calling a Javascript Function
    By FAS in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 18, 2012, 5:23 PM
  4. Calling JavaScript function
    By UserClarion in forum 1.x Help
    Replies: 2
    Last Post: Dec 30, 2011, 10:23 AM
  5. Calling js function inside a child tab
    By Rod in forum 1.x Help
    Replies: 2
    Last Post: Jul 23, 2009, 12:24 PM

Posting Permissions