473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cusotm Image button and themes

CK
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;
}
}
}
Oct 5 '06 #1
2 2431
I did a rollover image that was inherited from the image class. To get the
client side url of the images (and be able to use the ~), which I am
assuming is your issue, use ResolveClientUrl in your RenderControl method
(or in a function you call to help build the HTML output).

return base.ResolveClientUrl(_swapImageUrl);
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"CK" <c_**********@hotmail.comwrote in message
news:VI*****************@newssvr12.news.prodigy.co m...
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;
}
}
}

Oct 6 '06 #2
CK
Thanks for the reply. I did try that before and it didn't work, but it's
good to know what that method is used for. When I used it, the method
returned an absolute path for the website based on the location of the page
containing the control. My problem is that the theme information is located
at \\WebSite\App_Themes\MyTheme\ with the images for that theme located at
\\WebSite\App_Themes\MyTheme\Images and most of the pages of my site have a
path similar to \\WebSite\MyWebPage.aspx. All of the other skin information
for traditional asp controls contains properties like ImageUrl="images\mypic.gif"
and they work correctly. Using Reflector, I was able to determine that, at
some point, the page itself iterates through its controls and applies skin
information, which I'm assuming also includes adjusting the paths to any
skin information to absolute paths. For some reason, the paths on this
custom control and its parent are not being adjusted to include the skin
path (when I view the source of the page, the image src for the custom
control is still "images\mypic.gif" where all of the other paths have been
changed to "App_Themes\MyTheme\images\mypic.gif").
I'm thinking there has to be some type of attribute I am missing or some
type of method I need to implement to get this custom control to be included
when the page is adjusting the paths for the skin information

TIA
~CK

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@TK2MSFTNGP04.phx.gbl...
>I did a rollover image that was inherited from the image class. To get the
client side url of the images (and be able to use the ~), which I am
assuming is your issue, use ResolveClientUrl in your RenderControl method
(or in a function you call to help build the HTML output).

return base.ResolveClientUrl(_swapImageUrl);
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"CK" <c_**********@hotmail.comwrote in message
news:VI*****************@newssvr12.news.prodigy.co m...
>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;
}
}
}


Oct 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Peter | last post by:
Can Anybody tell me why my toolbar button's image is missing when my app is run, While the image is well enough in design time ?
4
by: Sean | last post by:
My experience now working with master pages on and off for 6 months is that they can be very dangerous when working with themes. One example in particular is the changes I made to my banner menu...
6
by: Clinton Farleigh | last post by:
Hi, I was going to ask a question, but I think I've answered it so now I am going to rant about how crappy ASP.NET themes are instead. As I've indicated above, my problem today is with themes....
3
by: WT | last post by:
Hello, I need to list all available themes for a .NET app, is there any API in ..NET2 for this or should I explore the folder files using IO methods ? Thanks for indication CS
11
by: New Bee | last post by:
Hi, I have been looking at Themes and Skins today and now resonably understand how they work at a ground level. But I have a couple of questions. 1. ) StyleSheetTheme I dont understand...
0
by: moni.aggarwal | last post by:
-------------------------------------------------------------------------------- Hi I have made a httpmodule to control my themes.I have an image in my skin file of my apptheme folder. But the...
1
by: swc76801 | last post by:
I desperately need help. My understanding of CSS is non-existent. I have a store http://astore.amazon.com/texasheat-20 with Amazon.com. According to the information from Amazon.com "Write your own...
11
by: Evolution445 | last post by:
I got this code, and it somehow doesnt work. <TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center"> <TR> <TD background="{image-path}navfiller.gif" HEIGHT=40...
17
by: govolsbaby | last post by:
Is there a way to leave the button forecolor unchanged when it is disabled? I have multiple buttons on the form and depending on various user inputs, some will or will not be enabled but I'd...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.