在母版页中动态绑定菜单项 [英] Binding Menu item dynamically in master page

查看:113
本文介绍了在母版页中动态绑定菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页中使用菜单控件和"xmldatasource",以及用于绑定数据的".XSL"文件.
我正在从数据库中检索"URL"并动态绑定数据.我使用的是不继承母版页的登录页.我有一个从登录页重定向的索引页,它继承了母版页,但是此页的url不存储在数据库中.索引页不, t给出任何错误并带有母版页,但是当我单击任何菜单项时,它将引发异常无法使用前导...退出顶级目录上方"
请解决问题.

I am using a menu control and a "xmldatasource" in a master page and a ".XSL" file for binding data.
I am retrieving "url" from database and bind the data dynamically. I am using a login page which doesn''t inherit the Master page.I have a index page which is redirected from login page and it inherits master page but the url of this page doesn''t store in database.Index page doesn,t give any error and comes with master page but when I click any menu item it throws exception "cannot use a leading...to exit above the top directory"
Please solve the problem.

推荐答案

这意味着您的网页所引用的内容位于页面上一级的文件夹中,但您的页面却是已经在网站的根文件夹中,因此相对路径无效.

这可能是由于在超链接控件上使用了〜/something".
当物理文件与友好URL位于不同的目录级别时,ASP.NET在其生成的相对URL中使用太多../,从而产生此错误.

如果您不能只使用绝对URL,我相信您可以使用Page.ResolveUrl(〜/foo/bar")来获取正确的相对URL.
What this means is that your web page is referring to content which is in the folder one level up from your page, but your page is already in the website''s root folder, so the relative path is invalid.

It''s probably due to using "~/something", probably on a Hyperlink control.
When the physical file is at a different directory level from the friendly URL, ASP.NET uses too many ../''s in the relative URL that it generates, giving this error.

If you can''t just use an absolute URL instead, I believe that you can use Page.ResolveUrl("~/foo/bar") to get the proper relative URL.


检查这些博客
http://forums.asp.net/t/1700327.aspx/1 [ ^ ]
http://bytes.com/topic/asp-net/answers/553201-masterpages-dynamic-created-menus-disappearing [ ^ ]
--NDK
check these blog
http://forums.asp.net/t/1700327.aspx/1[^]
http://bytes.com/topic/asp-net/answers/553201-masterpages-dynamically-created-menus-disappearing[^]
--NDK


这篇关于在母版页中动态绑定菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆