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

M

mark4asp

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.
 
N

Nick Chan

<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
 
B

bruce barker

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)
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top