Create NavBar and NavBarItem via client side

WebDesktop 2.5 enhances its feature to allow user to create NavBar and NavBarItem from client side.

Here is the simple steps you need to follow:

– First of all, you simply need to simply drag WebNavPane control and HTML button from Toolbox to the WebForm.

WebNavPane control

– Then, switch to Source code to create a javascript function called Create_ClientSide(). The code will look like following:

<script type=”text/javascript”>

        function Create_ClientSide()

        {

            var nav = ISGetObject(“WebNavPane1″);

           

            var navbar = new WebNavBar();

            navbar.Text = “test”;

            navbar.Name = “test”;

            nav.AddBar(navbar);

           

            var item = new WebNavBarItem();

            item.Text = “1”;

            item.Name = “1”;

            navbar.AddBarItem(item);

           

            navbar.Click();

        }
    </script>


– Invoke function Create_ClientSide() using onclick event in HTML button. 

<input type=”button” onclick=”Create_ClientSide()” value=”Click to create NavBar from client side” />

– Compile and run the sample.  When you click the button, it will automatically add the NavBar along with its NavBarItem.

Run in browser

The sample is available to be downloaded in here. For more information, you can also access our knowledge base from the following link:
http://support.intersoftpt.com/KBArticle.aspx?aid=255

Should you have any comment please feel free to give one :)

Cheers.

 

Leave a Reply