Home All Groups Group Topic Archive Search About

get a filename for a bitmap in a skin

Author
13 Nov 2006 11:21 PM
David Thielen
Hi;

I want to get the filename for a bitmap in a skin. I have to get this in my
..cs file because it is for a control that inherits from HyperLinkField and
therefore it cannot have properties set in the skin file.

What I really need is the folder name of the theme to build a filename of
spp/App_Themes/theme_name/Images/button.gif

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Author
14 Nov 2006 9:46 AM
Steven Cheng[MSFT]
Hi Dave,

As for your scenario, you create a custom DataControlField (derived from
HyperlinkField), if you want to customize a certain field on the server
control, I think you should go through the following means:

** define a property on your custom control field class to let user define
skinID for other controls in the control field. And in your override
"InitializeCell code, you can register handler for any inner control's
event and programmtically apply the skin style for the certain controls.

For example, below is a simple custom HyperLinkField class and add a Load
handler for the Hyperlink which will programmatically apply the certain
skin to the hyperlink control:

=====================
public class MyHyperLinkField : HyperLinkField
    {
        private string _linkSkin;

        public string LinkSkinID
        {
            get { return _linkSkin; }
            set { _linkSkin = value; }
        }

        public override void InitializeCell(DataControlFieldCell cell,
DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
        {
            base.InitializeCell(cell, cellType, rowState, rowIndex);

            if (cellType == DataControlCellType.DataCell)
            {
                HyperLink link = cell.Controls[0] as HyperLink;


                if (link != null)
                {
                    link.SkinID = _linkSkin ;

                    link.PreRender += new EventHandler(link_Load);

                }
            }

        }

        protected void link_Load(object sender, EventArgs e)
        {
            HyperLink link = sender as HyperLink;

            link.ApplyStyleSheetSkin(link.Page);
        }
    }
====================

====use the custom LInkField in GirdView===========

<asp:GridView ID="GridView1" ................>
            <Columns>
               ................
                <ppsl:MyHyperLinkField .....
LinkSkinID="gridLink"></ppsl:MyHyperLinkField>
            </Columns>
        </asp:GridView>
=========================

As for path in the Theme, so far we haven't any means to programmatically
get it, however, Theme's path is always as below:

AppRoot/App_Themes/ThemeName/....

You can construct the Theme specific path according to the naming
convention.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
Author
14 Nov 2006 3:33 PM
David Thielen
Thank you - that makes perfect sense.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

> Hi Dave,
>
> As for your scenario, you create a custom DataControlField (derived from
> HyperlinkField), if you want to customize a certain field on the server
> control, I think you should go through the following means:
>
> ** define a property on your custom control field class to let user define
> skinID for other controls in the control field. And in your override
> "InitializeCell code, you can register handler for any inner control's
> event and programmtically apply the skin style for the certain controls.
>
> For example, below is a simple custom HyperLinkField class and add a Load
> handler for the Hyperlink which will programmatically apply the certain
> skin to the hyperlink control:
>
> =====================
> public class MyHyperLinkField : HyperLinkField
>     {
>         private string _linkSkin;
>
>         public string LinkSkinID
>         {
>             get { return _linkSkin; }
>             set { _linkSkin = value; }
>         }
>
>         public override void InitializeCell(DataControlFieldCell cell,
> DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
>         {
>             base.InitializeCell(cell, cellType, rowState, rowIndex);
>
>             if (cellType == DataControlCellType.DataCell)
>             {
>                 HyperLink link = cell.Controls[0] as HyperLink;
>
>                
>                 if (link != null)
>                 {
>                     link.SkinID = _linkSkin ;
>                    
>                     link.PreRender += new EventHandler(link_Load);
>                   
>                 }
>             }
>
>         }
>
>         protected void link_Load(object sender, EventArgs e)
>         {
>             HyperLink link = sender as HyperLink;
>
>             link.ApplyStyleSheetSkin(link.Page);
>         }
>     }
> ====================
>
> ====use the custom LInkField in GirdView===========
>
>  <asp:GridView ID="GridView1" ................>
>             <Columns>
>                ................
>                 <ppsl:MyHyperLinkField .....
> LinkSkinID="gridLink"></ppsl:MyHyperLinkField>
>             </Columns>
>         </asp:GridView>
> =========================
>
> As for path in the Theme, so far we haven't any means to programmatically
> get it, however, Theme's path is always as below:
>
> AppRoot/App_Themes/ThemeName/....
>
> You can construct the Theme specific path according to the naming
> convention.
>
> Hope this helps.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>

>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>