开发者

Set object param tag from code-behind

I want to embed video in object tag and I want to put the value of param from code-behind. But I'm not able to put the value from code-behind. Any idea where I'm getting wrong?

This is my code so far:

<object runat="server" id="object1">
    <param name="param1" value="www.youtube.com?id=123" runat="server" id="video1" />
    <param name="size" value="large" />
    <param name="category" value="wide" />
</object>

I want 开发者_如何学Cto change the value of param1 from code-behind.


Try this:

<object id="object1">
    <param name="<%= MyFunction() %>" value="www.youtube.com?id=123" id="video1" />
    <param name="size" value="large" />
    <param name="category" value="wide" />
</object>

In code behind, for example:

protected string MyFunction()
{
    return "param1Value";
}

Edit: removed both runat="server" - If those were only present for the purpose of using code behind to set the param, they are unnecessary for this solution.


Based on your markup I would think you can access it by id, such as:

video1.Attributes["value"] = "some value";

I've never used param tags on the server side though so there may be other issues at play...


I don't think you can do this without changing your tag a bit. Check out the links below for some info on why this is the case:

http://authors.aspalliance.com/aspxtreme/aspnet/syntax/server-sideobjecttagsglobalasax.aspx http://forums.asp.net/t/1389622.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜