all groups > visual studio .net general > august 2006 >
You're in the

visual studio .net general

group:

asp.net menu control - StaticItemTemplate / DynamicItemTemplate does not take any control


asp.net menu control - StaticItemTemplate / DynamicItemTemplate does not take any control Rolf Welskes
8/28/2006 9:35:47 PM
visual studio .net general:
Hello,

I have in a asp.net menu the following StaticItemTemplate:

<StaticItemTemplate>
<table runat="server" id="table01" border="1" bordercolor="blue"
cellpadding="4" cellspacing="4" >
<tr><td><%# Eval("Text") %> </td></tr>
</table>

</StaticItemTemplate>

This looks fine.

But it does not work.
If I run the program, first the cursor is that of a caret not as for click a
link.
Second, if I click on an item in the menu, you come not to the page of the
NavigationUrl.

For DynamicItemTemplate it's the same problem.

Any help would be fine.
Thank You.
Rolf Welskes


RE: asp.net menu control - StaticItemTemplate / DynamicItemTemplate does not take any control stcheng NO[at]SPAM online.microsoft.com
8/29/2006 12:00:00 AM
Hello Rolf,

As for the ASP.NET menu control, if we has used the "StaticItemTemplate"
and "DynamicItemTemplate " to customize the menu item, the control will
completely replace the original menu item html with our customized
template. And in such cases, if you still want the menu item to behave
like a hyperlink to other page, you need to add the linker in your custom
template or add some script code.

For example, we can add a HyperLink control in our custom template, like:

<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("Text") %>'
NavigateUrl='<%# Eval("NavigateUrl") %>'>

Or if the custom template has complex html structure and you want to
redirect the user when click on any part of the template section, you can
add a wrapper html hyperlink around the template and use javascript to
trigger the wrapper link's click event.

here is a simple example template demonstrate the two approaches:

========================
<StaticItemTemplate >
<a href="<%# ResolveUrl(Eval("NavigateUrl").ToString()) %>">
<table runat="server" id="table01" border="1"
bordercolor="blue" style="cursor:pointer"
cellpadding="4" cellspacing="4"
onclick="this.parentNode.click();">
<tr>
<td>
<asp:HyperLink ID="HyperLink1" runat="server"
Text='<%# Eval("Text") %>' NavigateUrl='<%# Eval("NavigateUrl")
%>'></asp:HyperLink>
</td>
</tr>
</table>
</a>
</StaticItemTemplate>
<DynamicItemTemplate>
<a href="<%# ResolveUrl(Eval("NavigateUrl").ToString()) %>">
<table runat="server" id="table01" border="1"
bordercolor="blue" style="cursor: pointer"
cellpadding="4" cellspacing="4"
onclick="this.parentNode.click();">
<tr>
<td>
<asp:HyperLink ID="HyperLink1" runat="server"
Text='<%# Eval("Text") %>' NavigateUrl='<%# Eval("NavigateUrl")
%>'></asp:HyperLink>
</td>
</tr>
</table>
</a>
</DynamicItemTemplate>
============================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button