Basic use of devexpress Asp.net (1) aspxbutton

Source: Internet
Author: User
The series of controls developed by devexpress are indeed very powerful, especially some data-bound controls, or even 0 Code You can achieve a very "strong" effect. I also need to use it in my work, so I just want to learn and sort it out. I just want to settle it. Some places may be wrong. I hope you can correct them!
Today I will mainly talk about the aspxbutton control, which is also Program The most widely used event, but the first use of the event does bring a little trouble. For example, when the client needs JavaScript code for necessary verification, we only need to add the onclientclick event when using aspbutton, the following code returns false in the program: < ASP: button ID = "Btnsubmit" Runat = "Server" Text = "Submit" Onclientclick = "Return btnclick ();"   />

Function Btnclick (){
If (Txtmemo. gettext () =   "" ){
Alert ( " Enter a valid value! " );
Return   False ;
}
}

When the btnclick event returns false, the program will no longer refer to the server-side code. However, aspxbutton does not support event registration and processing. When registering an event, add the <clientsideevents/> subnode in the <dxe: aspxbutton/> tag. As follows:Code
< Dxe: aspxbutton ID = "Btnsubmit" Runat = "Server" Clientinstancename = "Btnclientsubmit"
Text = "Submit"   >
< Clientsideevents Click = "Function validate (S, e ){
If (txtmemo. gettext () = ''){
Alert ('enter a valid value! ');
E. processonserver = false;
}
}"   />
</ Dxe: aspxbutton >

The above code will display an aspxbutton and register the client event click. In the click event, determine whether the txtmemo content is equal to ''. If it is equal to'', the user will be prompted, and set properties E. processonserver = false to prevent code running on the server.

E. processonserver (true/false)
gets or sets whether the program is executed on the server. After reading relevant information, if the aspx system control has the autopostback attribute, you can use E. processonserver to control whether the code is executed on the client or on the server. However, the processonserver depends on the autopostback attribute . If the control autopostback = "false", the processonserver attribute value does not work.
In addition to click, The aspxbutton client events include checkedchanged, gotfoucs, init, and lostfoucs. In addition, aspxbutton provides a series of client methods to set aspxbutton attributes, such as settext (value): Set the display value of the button; gettext (): Get the display value; setvisbile (bool ): set whether to display; getvisbile (): Get whether to display;
incallback (): Get a value, indicating whether a callback is being processed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.