Need button control that...

D

David Thielen

I need a button control that does the following:

1) Has 3 bitmaps for button, OnHover, and OnClick.
2) Is placed in a grid and has a url that includes a {0} in the url that is
set with a property from the data for that row of the grid.
3) Preferably has a text (for when the cursor is over it) that has a {0}
that is another property for that row's data.

I'm sure this can be done with the MS controls - but I can't find which/how.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
S

Steven Cheng[MSFT]

Hello Dave,

As for the Button control you mentioned, I think you may have two possible
options:

1. Use existing built-in server control and add some additional
customization on it. According to your requirments, I think the LinkButton
or HyperLink control will be prefered one.

2. Create a custom button control and add those functionality in it.

regardless of which approach you use, here are the suggestion on how you
can implement those requirements in the control:


** Has 3 bitmaps for button, OnHover, and OnClick.
=====================
for display different images for different status, you can consider use
java script to change the html element's background image property or
change different css class which has configured the image background.
Those script event like "onhover" is the correct one.


** Is placed in a grid and has a url that includes a {0} in the url that is
set with a property from the data for that row of the grid.
=============================
this could be done through databinding on the hyperlink's Url property


**Preferably has a text (for when the cursor is over it) that has a {0}
that is another property for that row's data.
===============================
This can be done through databinding on Hyperlink control' "ToolTip"
property.

#WebControl.ToolTip Property
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontro
l.tooltip.aspx


**And in some cases I need an OnClick that calls confirm to ask the user if
they are sure they want to perform that action.
==================================
This is also a javascript based solution, there are many web article
describing this detailedly:

#ASP.NET Popup Dialog - Confirm Delete - Javascript
http://davidhayden.com/blog/dave/archive/2004/03/16/178.aspx

#How to Confirm a Delete in an ASP.NET Datagrid...
http://www.dotnetjohn.com/articles.aspx?articleid=68

Please feel free to let me know if you have anything unclear.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hi;

I am getting most of this but I can't figure out how to get an onmouseover
on the inner <img> of a <asp:HyperLink> - it always is set for the HyperLink
<a href...> tag.

I'm thinking this might be a lot better to implement as a control anyways as
it is always a DataField that I am using it for and then I eleminate the
<TemplateField>... part.

Do you know of a good example of a control like HyperLinkField that has
source code available?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
S

Steven Cheng[MSFT]

Hello Dave,

Thanks for the reply,

Yes, if you directly use the built-in Hyperlink control, it may be a bit
hard to add Image in it ,and hyperlink (<a>) can only support a background
image. If you want to purely display an Image, you can completely render
out the following like html in your custom control. e.g

========================
<a id="a1" href="controlpage2.aspx" ><img id="imgLink"
src="http://www.asp.net/i/www_asp_net_logo.gif" /> </a>
===========

Or you can even do not use <a> , but only use <img> element and use
client-script to simulate hyperlink's redirect functionality. e.g

<img id="imgLink" src="http://www.asp.net/i/www_asp_net_logo.gif"
onclick="window.location.herf=newurl;" />

So far I haven't got any other existing control sample, you can have a
look at ASP.NET site's control gallery or in codeproject:

http://www.asp.net/default.aspx?tabindex=6&tabid=31

Also, you can use reflector tool to inspect the built-in hyperlink control
or image button control's code which can also provide much ideas on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Good job Dave,

Thanks for sharing them with us!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top