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.