Using the ClientScripts Property to Open the URL in a New Window
You can use the C1WebGroupHeader.ClientScripts property to open the URL in a new window when you click on the header or you can use the C1WebLinkItem.ClientScripts property to open the URL in a new window when you click on the item.
To open the URL in a new window for the first group:
1. Add the C1WebTopicBar control to your page.
2. Import the C1.Web.Command namespace:
Imports C1.Web.Command
C#
using C1.Web.Command;
3. Enter the following code in the Page_Load procedure to open the URL in a new window when you click on the first group in the Topic Bar:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Assign the variable name to the first group
Dim group1 As C1WebTopicBarGroup = CType(C1WebTopicBar1.Groups(0), C1WebTopicBarGroup)
'Assign the text name for the first group
group1.Text = "Software Development Tools"
'Assign the C1WebGroupHeader.ClientScripts property to execute the client side script when you click on the group
group1.ClientScripts.Add(New ScriptDef("onclick", "window.open('http://www.componentone.com','mywindow','width=400,height=200,scrollbars=yes')"))
'set the EnableExpandCollapse to false to prevent the group from collapsing when you click on the header
group1.EnableExpandCollapse = False
End Sub
C#
protected void Page_Load(object sender, EventArgs e)
{
C1WebTopicBarGroup group1 = (C1WebTopicBarGroup)C1WebTopicBar1.Groups[0];
group1.Text = "Software Development Tools";
//Assign the C1WebGroupHeader.ClientScripts property to execute the client side script when you click on the header
group1.ClientScripts.Add(new ScriptDef("onclick","window.open('http://www.componentone.com','mywindow','width=400,height=200,scrollbars=yes')"));
//this will prevent the group from collapsing when you click on the header
group1.EnableExpandCollapse = false;
}
4. Run the application and click on the group in the topic bar.
The assigned URL will open in a new window.
To open the URL in a new window for the first item:
1. Add the C1WebTopicBar control to your page.
2. Import the C1.Web.Command namespace:
Imports C1.Web.Command
C#
using C1.Web.Command;
3. Enter the following code in the Page_Load procedure to open the URL in a new window when you click on the first item in the Topic Bar:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Assign the variable name to the first item in the group
Dim item1 As C1WebTopicBarItem = CType(C1WebTopicBar1.Groups(0).Items(0), C1WebTopicBarItem)
item1.Text = "Help Authoring Tool"
'Assign the C1WebLinkItem.ClientScripts property to execute the client side script when you click on the item
item1.ClientScripts.Add(New ScriptDef("onclick", "window.open('http://www.doctohelp.com','mywindow','width=400,height=200,scrollbars=yes')"))
End Sub
C#
protected void Page_Load(object sender, EventArgs e)
{
//Assign the variable name to the first item in the group
C1WebTopicBarItem item1 = (C1WebTopicBarItem)C1WebTopicBar1.Groups[0].Items[0];
item1.Text = "Help Authoring Tool";
//Assign the C1WebLinkItem.ClientScripts property to execute the client side script when you click on the item
item1.ClientScripts.Add(new ScriptDef("onclick", "window.open('http://www.doctohelp.com','mywindow','width=400,height=200,scrollbars=yes')"));
}
4. Run the application and click on the first item in the topic bar.
The assigned URL will open in a new window.
|