开发者

how to set the scr property of embed or object tag in code behind in asp.net

<object width="425" height="344">
  开发者_如何转开发  <embed src="PATH_TO_YOUR_FILE" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

how to set the scr property of embed or object tag in code behind in asp.net


Create a public property in code behind .cs file

public string EmbedSrc
{
    get; set;
}

set it in Page_Load

EmbedSrc = "PATH_TO_YOUR_FILE";

Then use the property in your asp.net markup code.

<object width="425" height="344">
    <embed src="<%= EmbedSrc %>" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

*Edit: * due to comments

You can make use of literal control

Place a literal control in markup code

<asp:Literal runat="server" ID="litEmbedObject"></asp:Literal>

Then set the text in Page_Load

litEmbedObject.Text = string.Format("<object width=\"425\" height=\"344\">" +
    "<embed src=\"{0}\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"344\"></embed></object>", "PATH_TO_YOUR_FILE");


I found that the code below worked well with my ASP.Net application. <embed src="C://YOURFOLDER/YOURFILE" type="application/x-shockwave-flash" width="425" height="344"/>

Mutantsfox

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜