ButtonX Primer

In many sites, you will have multiple buttons on a form allowing the user to save her work or cancel and be taken to a different page. If you use the standard asp:Button, it posts back to the existing page which is a wasted page-call because all you really want to do is take the user to a different page. You can use the PostBackUrl of the asp:Button control but it does an http post to the target, not an http get, which can cause odd behavior in the targeted page. All we really need is an asp:HyperLink-like control that looks like a button.

ButtonX is an extension of the Button class so it retains all behavior of the standard button. It adds a NavigateUrl property just like the asp:Hyperlink and when set, it will take the user to that page without posting-back to the existing page and without doing a post to the targeted page.

Specifications

Inherits System.Web.UI.WebControls.Button (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button(VS.80).aspx)

Properties

Name Description
NavigateUrl Gets or sets the Url to link to when button is clicked.

Examples

<asp:ButtonX id="btnCancel" runat="server" CausesValidation="False" CssClass="button" Text="Cancel" NavigateUrl="~/AppGroup/Default.aspx" />
 
btnRemove.NavigateUrl = String.Format("~/AppUser/Remove.aspx?AppUserId={0}", myAppUserId)
 
Share It:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Netvibes
  • Ping.fm
  • Reddit
  • StumbleUpon
  • Technorati