ASP.NET 在用户控件内设置对象标记的 Flash 文件路径

发布于 2024-08-19 16:31:39 字数 318 浏览 2 评论 0原文

我有一个 ASP.NET 用户控件,我想在其中使用 flashplayer 运行 flash 影片。我如何正确设置 flash 影片文件的路径,以便这可以在所有页面中工作,而不管文件夹如何。 IE;它应该在FolderA 中的页面和FolderASub1 中的页面(FolderASub1 位于FolderA 中)以及根文件夹中的页面中工作。我的Flash 文件驻留在根目录中名为FlashGallery 的文件夹中。我的用户控件驻留在根目录中的子文件夹中。

我不知道如何在这里使用〜。因为它(播放Flash的对象标签)不是服务器控件。 事实上,我也无法放置完整的相对路径。

有什么想法吗?

I have a an ASP.NET user control where i wanto run a flash movie using flashplayer.How can i set the path of flash movie file properly so that this would work in all pages irrespective of the folders. ie; it should work inside a page in FolderA and a page in FolderASub1 which is in FolderA and a page in the Root folder too.My Flash file resides in a Folder called FlashGallery in root.My User control resides in a Subfolder in Root.

I am not sure how can use ~ here .Since its(Object tag to play flash) not a server control.
And infact i cant place the full relative path too.

Anythoughts ?

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

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

发布评论

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

评论(4

天邊彩虹 2024-08-26 16:31:39

您可以使用基于根的路径:/FlashGallery/movie.swf

或者您可以在代码中生成路径字符串,并将其放置在 aspx 文件中,如下所示:

You can use a root-based path: /FlashGallery/movie.swf

Or you could generate a path string in your code, and place it in the aspx file like this:

丢了幸福的猪 2024-08-26 16:31:39

使用基于域根的绝对路径。而不是使用像这样的相对 url 路径

“mymovieplayer.fla”

“../mymovieplayer.fla”

执行此操作

“/flash/mymovieplayer.fla”

Use an absolute path based off the root of your domain. Instead of using a relative url path like

"mymovieplayer.fla"

or

"../mymovieplayer.fla"

do this

"/flash/mymovieplayer.fla"

揽清风入怀 2024-08-26 16:31:39

仅供参考:我使用这个(免费)控件:http://www.junasoftware。 com/servercontrols/swfobject.net/download.aspx

您可以使用“~”波浪号来使用站点根目录的相对路径,它将在母版页上工作,即使内容页面位于不同的目录中,您可以像这样使用它:

<%@ Register Assembly="SWFObject.Net" Namespace="Juna.Web.UI" TagPrefix="SWF" %>


免费!

FYI: I use this (Free)Control: http://www.junasoftware.com/servercontrols/swfobject.net/download.aspx

You can use the '~' tilde to use relative paths to the site root and it will work on a master page, even if content pages are in different directories, you can use it like this:

<%@ Register Assembly="SWFObject.Net" Namespace="Juna.Web.UI" TagPrefix="SWF" %>
.
.
.

Its FREEEEE!

听,心雨的声音 2024-08-26 16:31:39

如果您始终知道您的站点将安装到根目录,那么使用基于根目录的路径是可以的,但这并不现实,也是最佳实践。

如果我们可以使用服务器端相对路径前缀 ~/ 作为 ... 标记,那就太好了,但正如您所知,它不是用户控件,因此它只是按原样呈现给客户端。下面是一个技巧,允许您为客户端脚本块指定 ~/ 相对路径。

我基本上在页面、母版页或控件的代码后面使用 VirtualPathUtility 类和受保护的方法,它对我来说非常有效。

方法如下:

protected string GetPageRelativePath(string targetPath)
{
    return VirtualPathUtility.MakeRelative( Request.AppRelativeCurrentExecutionFilePath, targetPath );
}

下面是如何在脚本块中使用 ~/ 前缀:

<script type="text/javascript" src='<%=GetPageRelativePath("~/Scripts/MyScript.js") %>'></script>

本质上,您可以将其与其他 src 路径一起使用,甚至是图像或 Flash 文件的路径。

希望有帮助。

Using a root based path is fine if you always know your site will be installed to the root, but this isn't realistic and best practise.

It would've been nice of we could use the server side relative path prefix of ~/ for the ... tag, but as you know it's not a user control so it just gets rendered out to the client as is. Below is a trick to allow you to specify the ~/ relative path for a client side script block.

I essentially use the VirtualPathUtility class and a protected method on the code behind of the page, master page, or control and it works very well for me.

Here's the method:

protected string GetPageRelativePath(string targetPath)
{
    return VirtualPathUtility.MakeRelative( Request.AppRelativeCurrentExecutionFilePath, targetPath );
}

And here's how you can use the ~/ prefix in the script block:

<script type="text/javascript" src='<%=GetPageRelativePath("~/Scripts/MyScript.js") %>'></script>

Essentially you could use this with other src paths, even paths to images or Flash files.

Hope that helps.

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