<asp:Repeater ID="Repeater2" runat="server"> <ItemTemplate> <object ... <param name="movie" value='<%# "./movies/"+Eval("Movie") %>'> ... </object> </ItemTemplate> </asp:Repeater>
To pass dynamic data bould values to object we can use simple web control to write object html in to the page and by the render time we can inject dynamic values.
Control
namespace ActiveTest { public class ObjectControl : WebControl { public string ObjectUrl { get; set; } public int Width { get; set; } public int Height { get; set; } public ObjectControl() { this.Width = this.Height = 400; } protected override void Render(HtmlTextWriter writer) { string output = @" <object classid=""clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"" codebase=""http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"" width=""{1}"" height=""{2}""> <param name=""wmode"" value=""transparent""> <param name=""movie"" value='{0}'> <param name=""quality"" value=""high""> <embed src='{0}' quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" type=""application/x-shockwave-flash"" width=""{1}"" height=""{2}""> </embed> </object> ;"; writer.Write(string.Format(output, HttpContext.Current.Server.MapPath(this.ObjectUrl), this.Width, this.Height)); } } }
Page
<%@ Register Assembly="ActiveTest" Namespace="ActiveTest" TagPrefix="asp" %> <%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head2" runat="server"> </head> <body> <form id="form2" runat="server"> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:ObjectControl BannerUrl='<%# Eval("Banner") %>' Width="400" Height="100" ID="Control" runat="server" /> </ItemTemplate> </asp:Repeater> </form> </body> </html>
No comments:
Post a Comment