<commandbutton>

Related Topics
 

New to Version 4.0

 

If you're trying to add some client-side interactivity to your form, then you'll want to look into using <commandbutton>. At run-time, this tag will display as either a hyperlink, a standard HTML button, or as a click-able image. By itself, it doesn't do much, but when you assign Javascript to the "onclick" attribute, you can perform client-side tasks like calculating totals in fields, performing custom validation, hiding/showing certain parts of the form,  or whatever else you're able to do with Javascript and DHTML.

 

ATTRIBUTES:

text

Text to be displayed in the link or button. If display is "imagebutton" then this value will be the image's alternate text. [String value]  

class

Name of the CSS Class used to style the button (Optional) [String value]

style

Same as the HTML style attribute. It allows you to apply CSS styling to the element (e.g. "color: red; border: solid 1px black;")  (Optional). [String value]

display

Determines how the button will be rendered at runtime. Valid values are:

  • button - an HTML-style button will be displayed

  • imagebutton - a click-able image will be displayed. Be sure to set the imageurl attribute.

  • linkbutton - the button will be displayed as a hyperlink. This is the default value.

New to Version 4.0

imageurl

When display is set to "imagebutton" the value of this attribute will be used to find the image to display. Any valid URL pointing to a valid image file can be used.

height

Determines the height of the control at run-time using a measurement unit.

width

Determines the width of the control at run-time using a measurement unit.

onclick

Allows you to assign a client-side Javascript function to the button's OnClick event. You should always return false to prevent the control from posting-back to the server (doing so probably won't hurt anything, but it's a wasted round-trip that your form's user will have to sit through).  Javascript must be enabled in the user's browser for this to function.
 

 

EXAMPLES:

This example creates an HTML button that, when clicked, will call the Javascript function "calcTotal". The second Javascript command returns the value false so that the button doesn't perform an unnecessary postback to the server.

 

<commandbutton text="Calculate Total" display="button" class="CommandButton" onclick="calcTotal();return false;"/>