如何使用站点地图数据源在asp.net菜单中制作向下箭头?

发布于 2024-11-18 23:54:34 字数 2338 浏览 4 评论 0原文

我在 asp.net 中的菜单显示在右上角,但我希望它向下。这是我的网站的网址 http://www.theucreate.com/default.aspx< br> 在我们的操作菜单中,它显示右侧而不是向下的箭头。

CSS Code :
 .menuItem
        {
            border:Outset 1px black;
            background-color:Gray;
            font:14px Arial;
            color:White;
            padding:3px;
            position:relative; 
            z-index: 9999;
            width:125px; 
            text-align:center;


             }

菜单代码:

                            <asp:SiteMapDataSource ID="srcSiteMap" Runat="server" ShowStartingNode="false" />

站点地图代码:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode
    url="~/Default.aspx" 
    title="Home" 
    description="The home page of the Website">

    <!-- SiteMapPath Nodes -->
    <siteMapNode 
      title="Home"
      description="Home">

    </siteMapNode>

    <!-- Menu Nodes -->
    <siteMapNode 
      title="What we do"  
      description="Group of companies">
      <siteMapNode 
        url="~/UsingMenu/MenuSiteMap.aspx" 
        title="ADMG logo"  
        description="Abu Dhabi Marketing Group" />
        <siteMapNode
   url="~/UsingMenu/MenuSiteMap.aspx111"
   title="JamalMedia Logo"
   description="Jamal Media" />
        <siteMapNode
   url="Images/images/Emirates Palace.jpg"
   title="AFKARsoft Logo"
        description="AFKARsoft"/>
    </siteMapNode>

    <!-- TreeView Nodes -->
    <siteMapNode 
      title="Portfolio"  
       url=""
      description="">

    </siteMapNode>

      <siteMapNode
     title="Download"
     description="">

      </siteMapNode>

      <siteMapNode 
     title="News Blog"
     description="">

      </siteMapNode>


      <siteMapNode
     title="About Us"
     description="">

      </siteMapNode>
      <siteMapNode
     title="Awards"
     description="">

      </siteMapNode>


      <siteMapNode
     title="Contact Us"
     description="">

      </siteMapNode>

  </siteMapNode>

</siteMap>

My menu in asp.net show on the right corner, but I want it to be downward. Here is the url of my website http://www.theucreate.com/default.aspx
In what we do menu it shows the arrow on the right rather than down.

CSS Code :
 .menuItem
        {
            border:Outset 1px black;
            background-color:Gray;
            font:14px Arial;
            color:White;
            padding:3px;
            position:relative; 
            z-index: 9999;
            width:125px; 
            text-align:center;


             }

Menu Code :

                            <asp:SiteMapDataSource ID="srcSiteMap" Runat="server" ShowStartingNode="false" />

Site Map Code :

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode
    url="~/Default.aspx" 
    title="Home" 
    description="The home page of the Website">

    <!-- SiteMapPath Nodes -->
    <siteMapNode 
      title="Home"
      description="Home">

    </siteMapNode>

    <!-- Menu Nodes -->
    <siteMapNode 
      title="What we do"  
      description="Group of companies">
      <siteMapNode 
        url="~/UsingMenu/MenuSiteMap.aspx" 
        title="ADMG logo"  
        description="Abu Dhabi Marketing Group" />
        <siteMapNode
   url="~/UsingMenu/MenuSiteMap.aspx111"
   title="JamalMedia Logo"
   description="Jamal Media" />
        <siteMapNode
   url="Images/images/Emirates Palace.jpg"
   title="AFKARsoft Logo"
        description="AFKARsoft"/>
    </siteMapNode>

    <!-- TreeView Nodes -->
    <siteMapNode 
      title="Portfolio"  
       url=""
      description="">

    </siteMapNode>

      <siteMapNode
     title="Download"
     description="">

      </siteMapNode>

      <siteMapNode 
     title="News Blog"
     description="">

      </siteMapNode>


      <siteMapNode
     title="About Us"
     description="">

      </siteMapNode>
      <siteMapNode
     title="Awards"
     description="">

      </siteMapNode>


      <siteMapNode
     title="Contact Us"
     description="">

      </siteMapNode>

  </siteMapNode>

</siteMap>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

强辩 2024-11-25 23:54:34

这是该图像的萤火虫结果。

<img style="border-style:none;vertical-align:middle;" alt="Expand What we do" src="/WebResource.axd?d=dwnZhK7b4PUDsKPTU3AZnUtITQ9KjzrPTvWdHZ0MJ5F90CTN6V8nGd5pgOYaON4YzxrLgw8Gv5od1SOfZnP5XQ_U_OV-qIXKJzrb0MKwjSo1&t=634395197491956634">

我用谷歌搜索了这个问题,发现一个博客有类似的情况,可能会帮助他的代码解决你的问题。

protected void _siteMenu_ItemDataBound(object sender, System.Web.UI.WebControls.MenuEventArgs e)

{

// Reference the underlying SiteMapNode object...
MenuItem item = (MenuItem)e.Item;
SiteMapNode nodeFromSiteMap = (SiteMapNode)e.Item.DataItem;

string onImage = "";
string offImage = "";
string navUrl = "";

// If we have an imageUrl value, assign it to the menu node's ImageUrl property
if (nodeFromSiteMap["imageUrl"] != null)
{
onImage = System.Web.HttpContext.Current.Request.ApplicationPath + System.IO.Path.Combine("/Images/Elements/", nodeFromSiteMap["imageUrl"]);
offImage = System.Web.HttpContext.Current.Request.ApplicationPath + System.IO.Path.Combine("/Images/Elements/", nodeFromSiteMap["altImageUrl"]);
}
navUrl = nodeFromSiteMap["url"];

// These objects are necessary in order to capture the image object into a rendered html format
string src = offImage;
string toolTip = "";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htmWriter = new HtmlTextWriter(sw);
HtmlImage image = new HtmlImage();

image.Style.Add("border-style", "none");
MenuItem theMenuButton = new MenuItem();
theMenuButton.NavigateUrl = navUrl;
image.Src = src;

if (onImage != "" && onImage != null)
image.Attributes["onMouseOver"] = "this.src='" + onImage + "';";
if (onImage != "" && onImage != null)
image.Attributes["onMouseDown"] = "this.src='" + onImage + "';";
image.Attributes["onMouseOut"] = "this.src='" + offImage + "';";
image.RenderControl(htmWriter);
item.Text = sw.ToString();
}

在 asp.net 菜单控件中添加鼠标悬停在图像上
将自定义图标添加到特定菜单项

this is the firebug result for that image .

<img style="border-style:none;vertical-align:middle;" alt="Expand What we do" src="/WebResource.axd?d=dwnZhK7b4PUDsKPTU3AZnUtITQ9KjzrPTvWdHZ0MJ5F90CTN6V8nGd5pgOYaON4YzxrLgw8Gv5od1SOfZnP5XQ_U_OV-qIXKJzrb0MKwjSo1&t=634395197491956634">

i googled around for this problem and i find a blog which have similar situation and might help his code to solve your problem.

protected void _siteMenu_ItemDataBound(object sender, System.Web.UI.WebControls.MenuEventArgs e)

{

// Reference the underlying SiteMapNode object...
MenuItem item = (MenuItem)e.Item;
SiteMapNode nodeFromSiteMap = (SiteMapNode)e.Item.DataItem;

string onImage = "";
string offImage = "";
string navUrl = "";

// If we have an imageUrl value, assign it to the menu node's ImageUrl property
if (nodeFromSiteMap["imageUrl"] != null)
{
onImage = System.Web.HttpContext.Current.Request.ApplicationPath + System.IO.Path.Combine("/Images/Elements/", nodeFromSiteMap["imageUrl"]);
offImage = System.Web.HttpContext.Current.Request.ApplicationPath + System.IO.Path.Combine("/Images/Elements/", nodeFromSiteMap["altImageUrl"]);
}
navUrl = nodeFromSiteMap["url"];

// These objects are necessary in order to capture the image object into a rendered html format
string src = offImage;
string toolTip = "";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htmWriter = new HtmlTextWriter(sw);
HtmlImage image = new HtmlImage();

image.Style.Add("border-style", "none");
MenuItem theMenuButton = new MenuItem();
theMenuButton.NavigateUrl = navUrl;
image.Src = src;

if (onImage != "" && onImage != null)
image.Attributes["onMouseOver"] = "this.src='" + onImage + "';";
if (onImage != "" && onImage != null)
image.Attributes["onMouseDown"] = "this.src='" + onImage + "';";
image.Attributes["onMouseOut"] = "this.src='" + offImage + "';";
image.RenderControl(htmWriter);
item.Text = sw.ToString();
}

Adding mouse over image in asp.net menu control
add custom icon to specific menu item

酒几许 2024-11-25 23:54:34

该图像作为资源嵌入到 DLL 文件中。您必须更改该资源中的图像。但我认为微软必须有一个属性来让你更改该图像并用你自己的图像覆盖它。

That image is embedded inside a DLL file as a resource. You have to change the image in that resource. But I think Microsoft must have a property to let you change that image and override it with your own image.

白况 2024-11-25 23:54:34

我建议你获取 firefox 的 firebug 插件并检查箭头图标(安装插件后右键单击),你会在 img src 中找到它的文件路径。然后您可以通过谷歌搜索合适的向下箭头并将其上传到您通过检查元素找到的路径!

编辑

刚刚注意到它是一个奇怪的网络资源路径!我想您必须查看一下您的网络服务器,应该不会太难找到:)

或者

使用 XML 通过 XSLT 制作您自己的菜单,然后您可以完全控制其布局等:)

I suggest you get firebug addon for firefox and inspect the arrow icon (right click when addon installed), you will find its file path in the img src. then you can google for a suitable down arrow and upload this to the path you found from inspecting the element!

EDIT

just noticed its a odd web resource path ! guess you will have to have a look on your webserver shouldnt be too hard to find :)

Alternative

use the XML to make your own menu with XSLT then you can have full controll over its layout ect :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文