tags:

views:

45

answers:

4

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 ?

A: 

Using jQuery you can do like this

$("param[name=movie]").attr("value", new value);
rahul
I prefer to do it server side. The code snippet is the response for an ajax call.
Anthony
A: 

Untested, but I think this should work:

<% Response.Write("<embed src='" + value + "' width='350' height='350' />") %>
tzaman
A: 

Option 1

You could use server variable from Javascript function

Option 2

Add a placeholder or Literal and set object with its attribute as a string

miti737
+2  A: 

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>
...
markt