Dynamically set value of an elements attribute in ASP.NET

asp.net, html

Solution

You could add a property to your codebehind, say 'MyProperty', set the value during load, and then access that property right in your aspx...

In codebehind...

 public partial class _Default : System.Web.UI.Page
 {
    protected string MyProperty { get; set; }
    protected string MyOtherProperty { get;set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        MyProperty = "SomeValue";
        MyOtherProperty = "SomeOtherValue";
    }
 }

In the Aspx...

...
<object width="550" height="400">
<param name="movie" value='<%= MyProperty %>' />
<embed src='<%= MyOtherProperty %>' width="350" height="370"></embed>
</object>
...

Problem

I have some simple code in an aspx page ``` <object width="550" height="400"> <param name="movie" value='XXXX' /> <embed src='XXXX' width="350" height="370"></embed> </object> ``` I want to be able to dynamically set the value of XXXX. What is the best way to do this ?

Original source