Programatically adding an Object Tag to a TemplateColumn?

Discussion in 'ASP .Net Datagrid Control' started by ssp, May 25, 2005.

  1. ssp

    ssp Guest

    Hi All,

    I am trying to add flash movie to a templatecolumn of my datagrid. The
    flash movie takes variables to play different sample mp3 tunes. Below
    is my HTML Code:

    <asp:DataGrid id=dgTop10 runat="server" Width="100%"
    AutoGenerateColumns="False">
    <AlternatingItemStyle CssClass="dgAltItems"></AlternatingItemStyle>
    <ItemStyle CssClass="dgItems"></ItemStyle>
    <HeaderStyle CssClass="dgHeader"></HeaderStyle>
    <Columns>
    <asp:BoundColumn DataField="tArtist"
    HeaderText="Artist"></asp:BoundColumn>
    <asp:BoundColumn DataField="tSampleName"
    HeaderText="Title"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Sample">
    <ItemTemplate>
    [... This is where I want to add the flash file...]
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="SampleID"
    HeaderText="Code"></asp:BoundColumn>
    </Columns>
    </asp:DataGrid>

    Below Object tag that I want to add:

    <object data="common/playsample.swf" width="24" height="17"
    style="vertical-align: bottom;" type="application/x-shockwave-flash"
    VIEWASTEXT>
    <param name="type" value="application/x-shockwave-flash" />
    <param name="src" value="common/playsample.swf" />
    <param name="data" value="common/playsample.swf" />
    <param name="codebase" value="common/playsample.swf" />
    <param name="FlashVars" value="sample=test.mp3" /> <!-- The value of
    this Parameter is dynamic. It is explained below -->
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="common/playsample.swf" />
    <param name="loop" value="false" />
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    </object>

    The value of the parameter "FlashVars" above needs to be dynamic and
    something like:

    <param name="FlashVars" value="'sample='"+<%#
    DataBinder.Eval(Container.DataItem, "sampleFileName") %> />

    The question is, how do I go about it?

    I've tried using Response.Write statement in the HTML code to write the
    Object Tag above, but I always get "CS1026: ) expected" error. Below is
    the Response.Write code:

    <%= Response.Write("<object data=\"common/playsample.swf\" width=\"24\"
    height=\"17\" style=\"vertical-align: bottom;\"
    type=\"application/x-shockwave-flash\" VIEWASTEXT><param name=\"type\"
    value=\"application/x-shockwave-flash\" /><param name=\"src\"
    value=\"common/playsample.swf\" /><param name=\"data\"
    value=\"common/playsample.swf\" /><param name=\"codebase\"
    value=\"common/playsample.swf\" /><param name=\"FlashVars\"
    value=\"sample=test.mp3\" /><param name=\"allowScriptAccess\"
    value=\"sameDomain\" /><param name=\"movie\"
    value=\"common/playsample.swf\" /><param name=\"loop\" value=\"false\"
    /><param name=\"quality\" value=\"high\" /><param name=\"wmode\"
    value=\"transparent\" /></object>\n"); %>

    I hope someone can help me.

    SSP
     
    ssp, May 25, 2005
    #1
    1. Advertising

  2. ssp

    ssp Guest

    Got it...see the code below:

    <% Response.Write("<object data=\"common/playsample.swf\" width=\"24\"
    height=\"17\" style=\"vertical-align: bottom;\"
    type=\"application/x-shockwave-flash\" VIEWASTEXT><param name=\"type\"
    value=\"application/x-shockwave-flash\" /><param name=\"src\"
    value=\"common/playsample.swf\" /><param name=\"data\"
    value=\"common/playsample.swf\" /><param name=\"codebase\"
    value=\"common/playsample.swf\" /><param name=\"FlashVars\"
    value=\"TheSound=\n"); %><%#DataBinder.Eval(Container.DataItem,
    "FileName")%><%Response.Write("\" /><param name=\"allowScriptAccess\"
    value=\"sameDomain\" /><param name=\"movie\"
    value=\"common/playsample.swf\" /><param name=\"loop\" value=\"false\"
    /><param name=\"quality\" value=\"high\" /><param name=\"wmode\"
    value=\"transparent\" /></object>");
    %>

    Now I have to figure out how to play midi's in flash. I can play mp3's
    but not midi's. Wish me luck.

    SSP
     
    ssp, May 25, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev

    Adding <div> tag programatically

    DJ Dev, Apr 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    18,617
    Kevin Spencer
    Apr 2, 2004
  2. tshad
    Replies:
    0
    Views:
    330
    tshad
    Jan 25, 2005
  3. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  4. DJ Dev

    Adding <div> tag programatically

    DJ Dev, Apr 2, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    153
    Kevin Spencer
    Apr 2, 2004
  5. P
    Replies:
    7
    Views:
    148
    Tad McClellan
    Jan 12, 2007
Loading...

Share This Page