How do I emulate a LinkButton with this HTML clickable image?

Discussion in 'ASP .Net' started by mark4asp, Oct 19, 2007.

  1. mark4asp

    mark4asp Guest

    How do I emulate a LinkButton with this HTML clickable image?

    I have been using a LinkButton with an OnCommand event (it has a
    background image repeated). I want to replace the LinkButton with bit
    of html which looks like an image button but has the text as html -
    this uses two images (a matching left and right image) so that it has
    pretty rounded corners. PS: this is the kind of thing which is
    typically done when making css tabbed menus.

    My html looks like this:

    <div class="Button" id="btnReset"><a class="aButton"
    href="javascript:Clear();" title="Refresh"><span
    class="sButton">Refresh</span></a></div>

    The button displays fine and the two images look like a seamless
    whole. The point of this being that I can use any word apart from
    "Refresh" and the images will size themselves in the background to
    wrap the text nicely. The <a> element has the LHS part of the button
    and the sButton class references the RHS of the button.

    How do I fire a server side event from that "javascript:Clear();"?

    There is a matching button to this as well with a
    href="javascript:Search();"

    I have thought of storing a suitable value in a hidden form variable.
    Can I then submit the asp.net form from javascript?, and then select
    the server-side to execute depending on the value of the form variable
    (seems a pretty ugly way of doing things to me). What is the 'correct'
    way of doing this?

    I have no intention of making a user control as it would be more
    productive to ajaxify the page but, right now, I prefer something
    quick.
    mark4asp, Oct 19, 2007
    #1
    1. Advertising

  2. mark4asp

    Nick Chan Guest

    <input type="hidden" value="0" name="Clicked"/>

    <div class="Button" id="btnReset"><a class="aButton"
    href="javascript:Clear();document.forms[0].Clicked=1;document.forms[0].submit()"
    title="Refresh"><span
    class="sButton">Refresh</span></a></div>



    sub PageLoad

    if Request.Form("Clicked") = "1" then

    ' code here

    end if



    On Oct 19, 2:20 pm, mark4asp <> wrote:
    > How do I emulate a LinkButton with this HTML clickable image?
    >
    > I have been using a LinkButton with an OnCommand event (it has a
    > background image repeated). I want to replace the LinkButton with bit
    > of html which looks like an image button but has the text as html -
    > this uses two images (a matching left and right image) so that it has
    > pretty rounded corners. PS: this is the kind of thing which is
    > typically done when making css tabbed menus.
    >
    > My html looks like this:
    >
    > <div class="Button" id="btnReset"><a class="aButton"
    > href="javascript:Clear();" title="Refresh"><span
    > class="sButton">Refresh</span></a></div>
    >
    > The button displays fine and the two images look like a seamless
    > whole. The point of this being that I can use any word apart from
    > "Refresh" and the images will size themselves in the background to
    > wrap the text nicely. The <a> element has the LHS part of the button
    > and the sButton class references the RHS of the button.
    >
    > How do I fire a server side event from that "javascript:Clear();"?
    >
    > There is a matching button to this as well with a
    > href="javascript:Search();"
    >
    > I have thought of storing a suitable value in a hidden form variable.
    > Can I then submit the asp.net form from javascript?, and then select
    > the server-side to execute depending on the value of the form variable
    > (seems a pretty ugly way of doing things to me). What is the 'correct'
    > way of doing this?
    >
    > I have no intention of making a user control as it would be more
    > productive to ajaxify the page but, right now, I prefer something
    > quick.
    Nick Chan, Oct 19, 2007
    #2
    1. Advertising

  3. mark4asp

    bruce barker Guest

    the best approach is to create a usercontrol, implement
    IPostBackEventHandler and change the href to:

    string href="javascript:Clear();" +
    Page.ClientScript.GetPostBackEventReference(postbackOptions);


    -- bruce (sqlwork.com)

    mark4asp wrote:
    > How do I emulate a LinkButton with this HTML clickable image?
    >
    > I have been using a LinkButton with an OnCommand event (it has a
    > background image repeated). I want to replace the LinkButton with bit
    > of html which looks like an image button but has the text as html -
    > this uses two images (a matching left and right image) so that it has
    > pretty rounded corners. PS: this is the kind of thing which is
    > typically done when making css tabbed menus.
    >
    > My html looks like this:
    >
    > <div class="Button" id="btnReset"><a class="aButton"
    > href="javascript:Clear();" title="Refresh"><span
    > class="sButton">Refresh</span></a></div>
    >
    > The button displays fine and the two images look like a seamless
    > whole. The point of this being that I can use any word apart from
    > "Refresh" and the images will size themselves in the background to
    > wrap the text nicely. The <a> element has the LHS part of the button
    > and the sButton class references the RHS of the button.
    >
    > How do I fire a server side event from that "javascript:Clear();"?
    >
    > There is a matching button to this as well with a
    > href="javascript:Search();"
    >
    > I have thought of storing a suitable value in a hidden form variable.
    > Can I then submit the asp.net form from javascript?, and then select
    > the server-side to execute depending on the value of the form variable
    > (seems a pretty ugly way of doing things to me). What is the 'correct'
    > way of doing this?
    >
    > I have no intention of making a user control as it would be more
    > productive to ajaxify the page but, right now, I prefer something
    > quick.
    >
    bruce barker, Oct 19, 2007
    #3
    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. VB Programmer

    How to emulate Word mail merge in HTML?

    VB Programmer, May 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,126
    VB Programmer
    May 20, 2004
  2. Bart Schelkens

    Clickable image

    Bart Schelkens, Sep 9, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    419
    Sanjeeb Sarangi
    Sep 9, 2004
  3. DC Gringo
    Replies:
    0
    Views:
    353
    DC Gringo
    Oct 31, 2004
  4. Sathyaish
    Replies:
    3
    Views:
    3,085
    Sathyaish
    Sep 8, 2005
  5. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    175
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page