Wednesday, August 11, 2010

How to pass dynamic (databound) fileds to html object

With html object we cant use data binding expressions inside the object tag.
<asp:Repeater ID="Repeater2" runat="server">
        <object ...
            <param name="movie" value='<%# "./movies/"+Eval("Movie") %>'>

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.
namespace ActiveTest
    public class ObjectControl : WebControl
        public string ObjectUrl { getset; }
        public int Width { getset; }
        public int Height { getset; }
        public ObjectControl()
            this.Width = this.Height = 400;
        protected override void Render(HtmlTextWriter writer)
            string output = @"
                <object classid=""clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"" 
                width=""{1}"" height=""{2}"">
                <param name=""wmode"" value=""transparent"">
                <param name=""movie"" value='{0}'>
                <param name=""quality"" value=""high"">
                <embed src='{0}' quality=""high"" 
                    type=""application/x-shockwave-flash"" width=""{1}"" height=""{2}""> </embed>                   


<%@ Register Assembly="ActiveTest" Namespace="ActiveTest" TagPrefix="asp" %>
<%@ Page Language="C#" %>
<html xmlns="">
<head id="Head2" runat="server">
    <form id="form2" runat="server">
    <asp:Repeater ID="Repeater1" runat="server">
                BannerUrl='<%# Eval("Banner") %>' 
                runat="server" />

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...