Programatically adding an Object Tag to a TemplateColumn?

S

ssp

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
 
S

ssp

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top