|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
get a filename for a bitmap in a skinHi;
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 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. Thank you - that makes perfect sense.
-- Show quoteHide quotethanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "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. > > >
Login control - image button with text over it
how to get selectedvalue of radiobuttonlist in Javascript? looping through formview controls List Box : help preventing duplicate items GridView EnableSortingAndPagingCallBacks Select command. Accessing USER CONTROL which is inside Masterpage through Another USER Control inside normal page. Use CSS in themes StyleSheetTheme not working Session sharing between ASP and ASP.NET Login HelpPageIconUrl is the help link |
|||||||||||||||||||||||