在asp.net中使用对象标签 [英] Using Object tags in asp.net
问题描述
我有这个网站code在一个aspx页面嵌入视频:
I have this html code for embedding a video in an aspx page:
<OBJECT ID="MediaPlayer" WIDTH="192" HEIGHT="190" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject">
<PARAM NAME="FileName" VALUE="videofilename.wmv">
<PARAM name="autostart" VALUE="false">
<PARAM name="ShowControls" VALUE="true">
<param name="ShowStatusBar" value="false">
<PARAM name="ShowDisplay" VALUE="false">
<EMBED TYPE="application/x-mplayer2" SRC="videofilename.wmv" NAME="MediaPlayer"
WIDTH="192" HEIGHT="190" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"> </EMBED>
</OBJECT>
问题是,我想从我的C#code-背后设置其参数指标(如,路径的文件播放)。
The thing is, I want to set its parameters from my C# code-behind (f.e., the path to the file to be played).
我知道我应该添加 =服务器
但是这不是唯一的东西。的$ C $的c-后面不不管识别的类型的MediaPlayer的任何元素。 (我试图从访问我的的Page_Load(..)
)
I know I should add runat="server"
but that's not the only thing. The code-behind doesn't recognize any element of the type MediaPlayer no matter what. (I'm trying to access it from my Page_Load(..)
)
我应该怎么做呢?
10倍
推荐答案
创建一个 HtmlGenericControl
。您可以设置通过属性
属性通过您的codebehind的属性。并通过控件添加子元素
。
Create a HtmlGenericControl
. You can set the attributes through the Attributes
property via your codebehind. And add the sub-elements through Controls
.
HtmlGenericControl obj = new HtmlGenericControl("object");
HtmlGenericControl embedTag = new HtmlGenericControl("embed");
embedTag.Attributes["type"] = "application/x-mplayer2";
obj.Controls.Add(embedTag);
flashPlaceHolder.Controls.Add(obj);
这篇关于在asp.net中使用对象标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!