Web.sitemap and target of the URL

G

Guest

I have a web.sitemap file that has the url title and description. I then
have this attac attached to a menu. I want some of my menu choices to open
up in a page in a new window ie _blank as target. How do I do this with a
web.sitemap file
 
G

Guest

I was able to get window.open to work, as well as target='_blank'. Try this:

For target - In your web.sitemap file, add an XML attribute called "target".
(<siteMapNode title="Durham" url="http://www.website.com/Durham.pdf"
pop_up="" target="_blank"/>) This attribute is not required for every node.

For window.open - In your web.sitemap file, add an XML attribute called
"pop_up". You will have to add this to every node that contains a "URL"
attribute. Set to "" when using a URL, set to the url when using pop_up. URL
attribute must have a value.
(<siteMapNode title="Durham" url="duh" pop_up_width="210"
pop_up_height="210" pop_up="http://www.website.com/Durham.pdf"/>)

Optionally you can set a height and width attribute in your web.sitemap file.

Then in your code...

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
e.Item.Target = ((SiteMapNode)(e.Item.DataItem))["target"];

if (((SiteMapNode)(e.Item.DataItem))["pop_up"] != "")
{
e.Item.NavigateUrl = "javascript:OpenWindow('" +
((SiteMapNode)(e.Item.DataItem))["pop_up"] + "'," +
((SiteMapNode)(e.Item.DataItem))["pop_up_width"] + "," +
((SiteMapNode)(e.Item.DataItem))["pop_up_height"] + ")";
}
}

You will need to add this to your .aspx file...

<script language="javascript">
function OpenWindow(URL,W,H)
{
var WindowName = "MyPopup";
var Features = "width=" + W + ",height=" + H + ",location=no,
toolbar=no, menubar=no, resizable";
window.open(URL, WindowName, Features);
}
</script>

and lastly - add this to your <asp:Menu tag...

OnMenuItemDataBound="Menu1_MenuItemDataBound"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top