get a filename for a bitmap in a skin

D

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
 
S

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.
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top