开发者

Which component should i use?

开发者 https://www.devze.com 2022-12-31 02:31 出处:网络
I am using the <a> element to increase the font size in my webpage. <a href=\"javascript:increaseFontSize();\">+</a>

I am using the <a> element to increase the font size in my webpage.

<a href="javascript:increaseFontSize();">+</a>

T开发者_JAVA技巧he problem with it is that i cannot set a background image.

So what component should i choose from the VS2008 toolbox that has OnClientClick property and does not post-back?

For examaple, i set the OnClientClick property in a ImageButton, but the postback is executed after the ClientSide click


The element has to be a block element to be able to have a background image. You shouldn't use a link anyway, as it's not really a link to anywhere.

It doesn't have to be a server control out of the toolbox, server controls tend to have extra code added to them to do postbacks. You can simply use a div element and style it to look any way you want. For example:

HTML:

<div class="increase" onclick="increaseFontSize();">+</div>

CSS:

.increase { width: 20px; height: 20px; background: url(button.gif); color: #ccc; }
.increase:hover { color: #fff; }


Why would you want to use server controls? Can't you give a class to the anchor and define a background image:

<a href="javascript:increaseFontSize();" class="plus">+</a>

And in css:

.plus {
    background-image:url('plus.gif');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消