Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Custom Image Button help.

Reply
Thread Tools

Custom Image Button help.

 
 
CK
Guest
Posts: n/a
 
      10-05-2006
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;
}
}
}



 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      10-06-2006
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
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"CK" <> wrote in message
news:1zgVg.10242$ 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;
> }
> }
> }
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image button as a back button Chicagoboy27 ASP .Net 2 10-30-2006 05:00 PM
Custom Image Button help. CK ASP .Net Building Controls 1 10-06-2006 08:18 PM
Changing a HTML submit button that requests a Servlet, to an image button? How? James Storey via JavaKB.com Java 7 04-08-2005 06:10 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Image button acting like submit button. Russell ASP .Net 3 06-24-2004 01:55 AM



Advertisments
 



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