Set param tag of an object from code

I want to embed a video in an object tag, and I want to put the param value from the code. But I can not put the value from the code. Any idea where I'm wrong?

This is my code:

<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 to change the value param1from code.

+3
source share
3 answers

Try the following:

<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 the code behind, for example:

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

Edit: Removed both runat = "server" . If they were present only to use the code behind to set the parameter, they are not needed for this solution.

+4
source

Based on your markup, I think you can access it by id, for example:

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

param , ...

0

I do not think you can do this without changing your tag. Check out the links below to find out why this is so:

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

0
source

Source: https://habr.com/ru/post/1731899/


All Articles