添加对象或C#编程方式改变其参数/ ASP.Net [英] Adding Object or changing its parameter programmatically in C# / ASP.Net
问题描述
我要嵌入Windows媒体播放器到我的ASP.NET页面。
I want to embed Windows Media Player into my ASP.NET page. I do it with this code, which works fine:
<OBJECT id='mediaPlayer1' width="180" height="50"
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
<param name='fileName' value="http..">
<param name='animationatStart' value='true'>
<param name='transparentatStart' value='true'>
<param name='autoStart' value="false">
<param name='showControls' value="true">
<param name ="ShowAudioControls"value="true">
<param name="ShowStatusBar" value="true">
<param name='loop' value="false">
<EMBED type='application/x-mplayer2'
pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
bgcolor='darkblue' showcontrols="true" showtracker='-1'
showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="420" height="380"
src="http..."
autostart="true" designtimesp='5311' loop="false">
</EMBED>
</OBJECT>
我的问题是,我想改变URL在我的code后面,(像的这里但它是在VB,而不是C#),因为我加载的URL从数据库中。那么,有没有一种方法,在那里我可以在我的C#或部分 - 甚至better-添加此code,从C#的部分访问的URL?
My problem is, that I want to change the url in my code behind, (like here but it is in VB, not C#) because I load the Urls out of a database. So is there a way, where I can add this code in my c# part or -even better- to access the url from the c# part?
很抱歉,如果这是一个愚蠢的问题,但我搜索的时间现在..和this.FindControl(mediaPlayer1);不工作。
Sorry if this is a stupid question, but I searched for hours now.. and this.FindControl(mediaPlayer1); doesnt work.
推荐答案
重写渲染
方法。结果
编辑它以适合您的要求。
Override the Render
method.
Edit it to suite your requirements.
protected override void Render(HtmlTextWriter writer)
{
StringBuilder stringBuilder = new StringBuilder("<OBJECT "
+"ID='" +this.ClientID + "' "
+ "name='" + this.ClientID + "' "
+"CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'"
+"VIEWASTEXT"
);
stringBuilder.Append("<PARAM name='autostart' value='false'>");
stringBuilder.Append("<PARAM name='autoplay' value='false'>");
stringBuilder.Append("<PARAM name='URL' value='/" + fileUrl + "/" + selectedFile + "'>");
stringBuilder.Append("<PARAM name='rate' value='1'>");
stringBuilder.Append("<PARAM name='balance' value='0'>");
stringBuilder.Append("<PARAM name='enabled' value='true'>");
stringBuilder.Append("<PARAM name='enabledContextMenu' value='true'>");
stringBuilder.Append("<PARAM name='fullScreen' value='false'>");
stringBuilder.Append("<PARAM name='playCount' value='1'>");
stringBuilder.Append("<PARAM name='volume' value='100'>");
stringBuilder.Append("</OBJECT>");
divWindowsMediaPlayer.InnerHtml = stringBuilder.ToString();
base.Render(writer);
}
这篇关于添加对象或C#编程方式改变其参数/ ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!