JS Aspxbutton client-side Operation _javascript Skills

Source: Internet
Author: User
How JavaScript calls the parent window (Parent page)
The difference between window.parent and Window.opener JavaScript invokes the main window method
1:window.parent is an IFRAME page invoke the parent Page object
2:window.opener is the window.open open subpage Call parent Page object
The specific example will not be written.


Client-side validation of Aspxbutton in the Devexpress.web control
When we submit a face page with the. NET default Aspbutton, if client-side validation is required, we typically
You can write this, as follows:
<asp:button id= "Button1" runat= "Server" text= "submitted" onclientclick= "Validate ();"/>
If the verification fails to pass, in the JS function validate direct return false on it, but Aspxbutton can not,
It took a lot of effort to find the right approach, as follows:
<dxe:aspxbutton id= "btnapply" runat= "Server" onclick= "Btnapply_click" text= "Add" autopostback= "False" >
<clientsideevents click= "Validate"/>
</dxe:ASPxButton>
First, the Aspxbutton AutoPostBack property is set to False, and then a client click event is added.
This event is the implementation of some of the client's validation,
function validate (s, e) {
var select = document.getElementById ("ddlsection");
if (Select.value = = "0") {
Alert ("Please select a valid value!");
E.processonserver = false;
return false;
}
E.processonserver = true;
}
In this event, there is a very important attribute is processonserver, by setting the value of this property (True/false), you can let Aspxbutton whether or not to execute its server-side event program.

Detailed description Processonserver:
true: Processing on server-side events;
False: Handling on client events.

Note
Processonserver enables you to specify that the current button should handle the client's event or server-side events. If this property is set to False, a handler for the client event is executed, and the event is handled entirely at the client and not sent to the server. Set the Processonserver property to True, the end-processed event is on the server side, which triggers the registered server-side event.

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.