Need button control that...

Discussion in 'ASP .Net Web Controls' started by David Thielen, Oct 21, 2006.

  1. 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
    David Thielen, Oct 21, 2006
    #1
    1. Advertising

  2. Hi again;

    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.

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

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




    "David Thielen" wrote:

    > 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
    >
    >
    David Thielen, Oct 22, 2006
    #2
    1. Advertising

  3. 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.
    Steven Cheng[MSFT], Oct 23, 2006
    #3
  4. 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




    "Steven Cheng[MSFT]" wrote:

    > 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.
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    David Thielen, Oct 24, 2006
    #4
  5. David Thielen

    Guest

    , Oct 24, 2006
    #5
  6. 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.
    Steven Cheng[MSFT], Oct 24, 2006
    #6
  7. 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.
    Steven Cheng[MSFT], Oct 25, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    814
    Purvi T
    Oct 19, 2004
  2. Wes Weems
    Replies:
    1
    Views:
    468
    Natty Gur
    Jul 20, 2003
  3. AlecL
    Replies:
    2
    Views:
    806
    Alexey Smirnov
    Feb 12, 2007
  4. Replies:
    1
    Views:
    1,154
    Nathan Sokalski
    Sep 2, 2007
  5. Jim Gilligan
    Replies:
    0
    Views:
    149
    Jim Gilligan
    Sep 1, 2005
Loading...

Share This Page