|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom Image Button help.I am trying to extend the default asp:ImageButton to include an image for an enabled state and a second image for a disabled state. I currently did this by extending the ImageButton class in a custom control, creating a property for each of these images (EnabledImageUrl, DisabledImageUrl) and then overrode the Enabled property to change base.ImageUrl respectively. I am also trying to use Themes with this web site. The problem is (I can tell by looking in the page source) that when the image urls are stored in the custom control they are not being resolved to the actual path of the images (they are "image\<picName>.gif" in the skin file). Also, when the ImageUrl is set on the base class it is also not being resolved to the actual (theme) path. I was wondering if there is something I have to do with my custom control, some convenience method I can run to resolve these paths or if there is a specific point in the ASP page lifecycle that I have to plug in to in order for these paths to get resolved by default. public class MultiImageButton : ImageButton { private string _enabledImageUrl; private string _disabledImageUrl; public bool Enabled { get { return base.Enabled; } set{ base.Enabled = value; base.ImageUrl = value ? _enabledImageUrl : _disabledImageUrl; } } public string EnabledImageUrl { get { return _enabledImageUrl; } set{ _enabledImageUrl = value; if (Enabled) base.ImageUrl = Page._enabledImageUrl; } } public string DisabledImageUrl { get { return _disabledImageUrl; } set { _disabledImageUrl = value; if (!Enabled) base.ImageUrl = _disabledImageUrl; } } } The client side url is resolved in the base class with the method
ResolveClientUrl: base.ResolveClientUrl(base.ImageUrl); -- Show quoteHide quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA http://gregorybeamer.spaces.live.com ************************************************* Think outside of the box! ************************************************* "CK" <c_kettenb***@hotmail.com> wrote in message news:1zgVg.10242$e66.4943@newssvr13.news.prodigy.com... > Hello All, > I am trying to extend the default asp:ImageButton to include an image for > an > enabled state and a second image for a disabled state. I currently did > this > by extending the ImageButton class in a custom control, creating a > property > for each of these images (EnabledImageUrl, DisabledImageUrl) and then > overrode the Enabled property to change base.ImageUrl respectively. I am > also trying to use Themes with this web site. The problem is (I can tell > by > looking in the page source) that when the image urls are stored in the > custom control they are not being resolved to the actual path of the > images > (they are "image\<picName>.gif" in the skin file). Also, when the > ImageUrl > is set on the base class it is also not being resolved to the actual > (theme) > path. I was wondering if there is something I have to do with my custom > control, some convenience method I can run to resolve these paths or if > there is a specific point in the ASP page lifecycle that I have to plug in > to in order for these paths to get resolved by default. > public class MultiImageButton : ImageButton > { > private string _enabledImageUrl; > private string _disabledImageUrl; > public bool Enabled > { > get { return base.Enabled; } > set{ > base.Enabled = value; > base.ImageUrl = value ? _enabledImageUrl : > _disabledImageUrl; > } > } > > public string EnabledImageUrl > { > get { return _enabledImageUrl; } > set{ > _enabledImageUrl = value; > if (Enabled) > base.ImageUrl = Page._enabledImageUrl; > } > } > > public string DisabledImageUrl > { > get > { > return _disabledImageUrl; > } > set > { > _disabledImageUrl = value; > if (!Enabled) > base.ImageUrl = _disabledImageUrl; > } > } > } > > > CK wrote:
Show quoteHide quote > Hello All, I am wondering why you are doing this at the server. The usual way to do > I am trying to extend the default asp:ImageButton to include an image for an > enabled state and a second image for a disabled state. I currently did this > by extending the ImageButton class in a custom control, creating a property > for each of these images (EnabledImageUrl, DisabledImageUrl) and then > overrode the Enabled property to change base.ImageUrl respectively. I am > also trying to use Themes with this web site. The problem is (I can tell by > looking in the page source) that when the image urls are stored in the > custom control they are not being resolved to the actual path of the images > (they are "image\<picName>.gif" in the skin file). Also, when the ImageUrl > is set on the base class it is also not being resolved to the actual (theme) > path. I was wondering if there is something I have to do with my custom > control, some convenience method I can run to resolve these paths or if > there is a specific point in the ASP page lifecycle that I have to plug in > to in order for these paths to get resolved by default. > public class MultiImageButton : ImageButton > { > private string _enabledImageUrl; > private string _disabledImageUrl; > public bool Enabled > { > get { return base.Enabled; } > set{ > base.Enabled = value; > base.ImageUrl = value ? _enabledImageUrl : > _disabledImageUrl; > } > } > > public string EnabledImageUrl > { > get { return _enabledImageUrl; } > set{ > _enabledImageUrl = value; > if (Enabled) > base.ImageUrl = Page._enabledImageUrl; > } > } > > public string DisabledImageUrl > { > get > { > return _disabledImageUrl; > } > set > { > _disabledImageUrl = value; > if (!Enabled) > base.ImageUrl = _disabledImageUrl; > } > } > } > > > this is to handle it at the client without a trip to the server (you do need to send the two images to the client - preload them)
Javascript alert message problem
HTML can't find Caption property for datagrid Compiler Error Message: BC30456: 'btnGAT_onClick' is not a member of 'ASP.WebForm1_aspx' Nested Child Control Events Not Firing Paging In GridView bound to DataSet Calendar Web Control How can I alter the datatype of the data quiry from a database and store it into a gridview? Object data source, setting parameter source to Page.Partner.Guid Search in .NET DataFormatString Date |
|||||||||||||||||||||||