I have a ListView on a Page within a MasterPage and some very ugly ugly autogenerated IDs.
Such as..."ctl00_workbenchPlaceHolder_ListView1_ctrl1_LibItem2One"
Using swfobject.embedSWF(...) requires me to hand over the id of a div on my page that can be replaced with object/embed markup depending on the browser context.
My aim is to show the user a collection of video's they have uploaded to their website so they can review them and change some related data if desired.
Hence the ListView which is populated via a SQLDataSource which currently provides a number of URLs pointing to .flv files.
But it ain't gonna work if I put a <div id="replaceme"></div>' in my user control because I may then have more than one id="replaceme" and poor swfobject won't like it.
So my evil solution is to put an <asp:Literal> in my usercontrol and build the script, function name and div tag id as a string.
ApplyVideoConfiguration is called if the library object retreived from the database is a video and switches to the relevant View of a MultiView control.
protected void ApplyVideoConfiguration()
{
MultiViewLibItem.ActiveViewIndex = 3;
string functionName = "MakeFlashFor_" + this.ClientID;
string divId = "fp" + this.ClientID;
VideoScriptLiteral.Text =
"<script type=\"text/javascript\">" +
"Sys.Application.add_load(" + functionName + ");" +
"function " + functionName + "(){" +
"swfobject.embedSWF('PanamaVideoThumbnail.swf', '" + divId + "', '140', '127', '10');" +
"};" +
"</script>" +
"<div id=\"" + divId + "\" ></div>" ;
}
I was wondering, just how bad a solution is this, I'm really completely inexperienced when it comes to best practices but my instincts are telling me this is bad, although it does succeed in the aim of embedding some Flash Player instances.
Can anyone help me make it beautiful?