Client ID returns null

Last post 06-25-2009, 1:13 AM by Amjad Sahi. 5 replies.
Sort Posts: Previous Next
  •  06-21-2009, 5:03 PM 184732

    Client ID returns null .NET

    Hi again,

    Got stuck with a problem. I need to fetch the worksheet's client id from the server.

    Here are the following code. Before pasting the code I would like to explain the scenario. Here, using a Asp.Net TreeView to load the list of the worksheets so that users don't have to scroll down to change the sheets. The NoScroll property is kept as true and the sheets are bigger enough.

     foreach (WebWorksheet wrksht in grdWeb.WebWorksheets)
                {
                    TreeNode twrksht = new TreeNode();
                    twrksht.Text = wrksht.Name;
                    string str_wrk = wrksht.ClientID;
                    str_wrk = wrksht.ID;
                    twrksht.NavigateUrl = "BLOCKED SCRIPTreturn getWorksheet(" + wrksht.ClientID + ")";
                    tAssumption.ChildNodes.Add(twrksht);
                }


    The following codes are assigned in the client side.

    function getWorksheet(wrkshid)
    {
        var elem = document.getElementById(wrkshid);
        elem.click();
    }

    The problem is whenever I check the value for the worksheets ClientID using the quick watch during execution. I can see only null values. Is there any solution for this please?

    Thanks & Regards

    Prithiraj

     
  •  06-22-2009, 1:21 AM 184759 in reply to 184732

    Re: Client ID returns null

    Hi Prithiraj,

    Please try the following code:

    foreach (WebWorksheet wrksht in grdWeb.WebWorksheets)

                {

                    TreeNode twrksht = new TreeNode();

                    twrksht.Text = wrksht.Name;

                    int index = wrksht.Index;

                    twrksht.NavigateUrl = "BLOCKED SCRIPTreturn getWorksheet(" + index + ")";

                    tAssumption.ChildNodes.Add(twrksht);

     }

     

     

    function getWorksheet(index)

    {

        var sheet = document.getElementById("grdWeb_TAB" + index);

        if (sheet != null)

            sheet.click();

    }

     

    The id of worksheet in page is combined with name of GridWeb, the constant string “_TAB” and the index of the worksheet. Please check the source of the page for reference.

     

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  06-23-2009, 4:58 PM 185182 in reply to 184759

    Re: Client ID returns null

    Hi Thanks again,

    The code doesnt seem to work. It returns "The page cannot be found" error in the browser. What could be the reason and possible solution. The URL I get while clicking on the node is http://localhost/GridWebOnVS2005/group/BLOCKED SCRIPTreturn getWorksheet(1).

    C#__
      twrksht.NavigateUrl = "BLOCKED SCRIPTreturn getWorksheet(" + index + ")";

    JavaScript__
    function getWorksheet(index)

    {

        var sheet = document.getElementById("grdWeb_TAB" + index);

        if (sheet != null)

        sheet.click();

                       }

    I think, am missing something

    One more thing, I need to ask, How can we freeze the header?

    I look forward to your reply.

    Thanks & Regards

    Prithiraj Sengupta


     
  •  06-24-2009, 1:38 AM 185218 in reply to 185182

    Re: Client ID returns null

    Attachment: Present (inaccessible)
    Hi Prithiraj,

    In fact "Java....ipt:" is changed to "BLOCKED SCRIPT..", so I will attach here a screen shot of the line of code, please change your line of code according to the screen shot of the line of code,
    We have tested successfully with the TreeView control provided by VS.NET 2005.

    Thank you.





    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  06-24-2009, 2:04 PM 185339 in reply to 185218

    Re: Client ID returns null .NET

    Hi Amjad,

    Thanks for the reply. The thing worked now in IE. Do you know anything equivalent to sheet.click() event for mozilla? It works in IE well, but doesnt work in mozilla. Browser sniffing is restricted in mozilla. One more thing I need to ask you.. i.e I need to freeze the header of a web grid in Mozilla, it works fine with IE.

    Regards
    Prithiraj Sengupta

     
  •  06-25-2009, 1:13 AM 185379 in reply to 185339

    Re: Client ID returns null

    Hi,

    Please try the following script for Mozilla and IE:

    function getWorksheet(index)

    {

        var sheet = document.getElementById("grdWeb_TAB" + index);

        if (sheet != null)

        {

            if (document.all) {

                sheet.click();  //IE

            }

            else// not IE

                var e = document.createEvent('MouseEvents');

                e.initEvent('click', true, true);

                sheet.dispatchEvent(e);

            }

        }

    }

     

    To freeze header part:

    grdWeb.WebWorksheets[0].FreezePanes(2, 0, 2, 0);

     

     

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
View as RSS news feed in XML