Microsoft ASP. NET Ajax framework (3) DOM elements

Source: Internet
Author: User
Vs2008, C #3.0

ASP. NET Ajax core library provides a wide range of client-side JavaScript extensions. This article mainly mentions some function extensions for operating DOM elements on pages. These extensions allow us to more easily access page elements, customize event handler, and effectively isolate the differences between different browsers.

To achieve this function, there are two classes under the SYS. UI name control: SYS. UI. domelement, SYS. UI. domevent


1. SYS. UI. domelement
sys. UI. domelement. getelementbyid (string ID, element)
get the page element object, which is equivalent to $ get ()
the Element Parameter indicates that the object can be searched in the subnode of the element, if no value is found, null var o = sys. UI. domelement. getelementbyid ( " txtusername " );
O. value = " guozhijian " ;

sys. UI. domelement. getlocation (element)
obtain the position X, Y var location = sys. UI. domelement. getlocation ($ Get ( " txtusername " ));
var L = location. x;
var T = location. y;

sys. UI. domelement. setlocation (element, number X, number y)
set the location of the element, which is related to the parent node. If the position of the parent node is set to absolute or relative, this position is relative to the parent node, otherwise it is relative to the form or frame position sys. UI. domelement. setlocation ($ Get ( " txtusername " ), 0 , 0 );

sys. UI. domelement. getbounds (element)
obtains the boundary information of the element. var B = sys. UI. domelement. getbounds ($ Get ( " txtusername " ));
var height = B. height;
var width = B. width;
var x = B. x;
var y = B. y;

SYS. UI. domelement. addcssclass (element, string classname)
Add CSS class to element < Style Type = " Text/CSS " >
. Flatborder {Border: solid 1px # ff0000 ;}
</ Style >

SYS. UI. domelement. addcssclass ($Get("Txtusername"),"Flatborder");

SYS. UI. domelement. removecssclass (element, string classname)
Remove the CSS class of the element.
SYS. UI. domelement. togglecssclass (element, string classname)
If the element already has this CSS class, remove it. Otherwise, add
SYS. UI. domelement. containscssclass (element, string classname)
Determine whether the element has the CSS class.

2. SYS. UI. domevent

SYS. UI. domelement. addhandler (element, string eventname, function handler)
Equivalent to $ addhandler
Subscribe to the event processing function and pass the EVT parameter SYS. UI. domevent instance. Through this EVT parameter, you can obtain information about the event. SYS. UI. domevent. addhandler ($ Get ( " Btncommit " ), " Mousedown " , Btncommitmousedown );
Function btncommitmousedown (EVT) {

}

SYS. UI. domelement. removehandler (element, string eventname, function handler)
Equivalent to $ removehandler
Remove event processing functionsSYS. UI. domevent. removehandler ($Get("Btncommit"),"Mousedown", Btncommitmousedown );

SYS. UI. domelement. addhandlers (element, Object events, handlerowner)
What should I do? Batch subscription event handling methodSYS. UI. domevent. addhandlers ($ Get ( " Btncommit " ), {"Click": Btncommitclick,"Keypress": Btncommitkeypress} );

Function btncommitclick (EVT) {
Alert (EVT. type );
}
Function btncommitkeypress (EVT) {
Alert (EVT. type );
}

SYS. UI. domelement. clearhandlers (element)
Is to remove all event subscriptions in batches.

Note: The image is taken from ASP. NET Ajax in action.

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.