Custom Image Button help.

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Custom Image Button help.

    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 Guest

  2. Similar Questions and Discussions

    1. Button Component with image instead of the button
      I want to use the button component which will trigger data from an XML file to populate a combo box with data from an xml file, but rather than the...
    2. Misplaced custom button text
      Hi all, I just want to create a custom web button, but the button text appears in the top left corner of IE6! Can someone nice please pinpoint...
    3. Do not have Custom Page Button
      Acrobat 6 . PDF printer. Cannot add custom page size. Another computer in office has Pro and he has the option.
    4. How do I create a custom button component?
      Recently upgraded to the MX2004 suite and have been getting reaquainted with Flash for the first time since v5 I'm trying to do something which I...
    5. Custom Lingo For Return Button
      Hi All, I'd like to set up a return button so that when the user clicks on it he/she will be taken back to their point of origin in the movie. ...
  3. #2

    Default Re: Custom Image Button help.

    The client side url is resolved in the base class with the method
    ResolveClientUrl:

    base.ResolveClientUrl(base.ImageUrl);


    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    [url]http://gregorybeamer.spaces.live.com[/url]

    *************************************************
    Think outside of the box!
    *************************************************
    "CK" <c_kettenbach@hotmail.com> wrote in message
    news:1zgVg.10242$e66.4943@newssvr13.news.prodigy.c om...
    > 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;
    > }
    > }
    > }
    >
    >
    >

    Cowboy \(Gregory A. Beamer\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139