Typical JavaScript examples of Asp.net

Source: Internet
Author: User

DropdownlistExample of refreshing.XML.

For example, text Verification!

The following is an example of a Single-choice button without refreshing the front-end.Post it as soon as possible

<Script language = "JavaScript">

Function setbutton ()

{

If (document. All. rdobyhuman. Checked = true)

{

Document. All. cbohrput. Disabled = "";

Document. All. cboanswerhr. Disabled = "";

Document. All. cbogroup. Disabled = true;

}

If (document. All. rdobygroup. Checked = true)

{

Document. All. cbohrput. Disabled = true;

Document. All. cboanswerhr. Disabled = true;

Document. All. cbogroup. Disabled = "";

}

}

</SCRIPT>

<Asp: radiobutton id = "rdobyhuman" onclick = "setbutton ();" runat = "server" groupname = "totalgroup" Checked = "true" text ="By personnel"> </ASP: radiobutton>

E. Item. Attributes. Add ("onmouseover", "This. style. backgroundcolor = '# dee3e7 '");//The color of the mouse.

E. Item. Attributes. Add ("onmouseout", "This. style. backgroundcolor = 'white '");

E. Item. cells [2]. Attributes. Add ("onmouseover", "This. style. backgroundcolor = 'red '");

E. Item. cells [2]. Attributes. Add ("onmouseout", "This. style. backgroundcolor = 'white '");//Specify the color of a column

E. Item. cells [3]. Style ["cursor"] = "hand ";

E. Item. cells [4]. Attributes. Add ("onclick", "alert ('You missedIDYes:"+ E. Item. cells [4]. Text + "');");//Display Field

E. Item. cells [1]. Attributes. Add ("title ","'Red kids are unsolved, and the blue genie is resolved!'"+ E. Item. cells [0]. Text. tostring ());//DisplayTitle

E. Item. cells [0]. Attributes. Add ("onclick", "window. Open ('xinxiform. aspx? Idmain = "+ E. Item. cells [0]. Text +" ', '', 'toolbar = No, width = 260, Height = 200 ');");

Screen closed keys:

Function keydown (){//Right-click,CTRL + n,Shift + F10,F5Refresh and return key

// Alert ("ASCIICodeYes:"+ Event. keycode );

If (window. event. altkey )&&

(Window. event. keycode = 37) | //ShieldAlt +Direction keyBytes

(Window. event. keycode = 39 ))){//ShieldAlt +Direction key→

Alert ("You are not allowed to useAlt +Direction keys forward or backward webpage!");

Event. returnvalue = false;

}

If (event. keycode = 8) | //Unmask undefined deletion key

(Event. keycode = 116) | //ShieldF5Refresh key

(Event. keycode = 112) | //ShieldF1Refresh key

(Event. ctrlkey & event. keycode = 82) {// Ctrl + R

Event. keycode = 0;

Event. returnvalue = false;

}

If (event. ctrlkey) & (event. keycode = 78 ))//ShieldCTRL + n

Event. returnvalue = false;

If (event. shiftkey) & (event. keycode = 121 ))//ShieldShift + F10

Event. returnvalue = false;

If (window. event. srcelement. tagname = "A" & window. event. shiftkey)

Window. event. returnvalue = false ;//ShieldShiftAdd the left mouse button to open a new webpage

If (window. event. altkey) & (window. event. keycode = 115 )){//ShieldAlt + F4

Window. showmodelessdialog ("about: blank", "", "dialogwidth: 1px; dialogheight: 1px ");

Return false ;}

}

1.Oncontextmenu = "window. event. returnvalue = false"Will completely shield the right mouse button 

2.<Body onselectstart = "Return false">Cancel selection and prevent Replication 

3.Onpaste = "Return false"Do not paste 

4.Oncopy = "Return false;" oncut = "Return false ;"Prevents replication; prevents Cutting

5.<LINK rel = "shortcut icon" href = "favicon. ICO"> IEChange to your own icon in front of the address bar 

6.<LINK rel = "bookmark" href = "favicon. ICO">Show your icons in favorites 

7.<Input style = "ime-mode: Disabled">Disable Input Method

8.Always carry the framework 

<Script language = "JavaScript"> <! --

If (window = top)

Top. Location. href = "frames.htm"; file: // frames.htmFor the frame web page 

// --> </SCRIPT>

9.Prevent being attackedFrame

<Script language = JavaScript> <! --

If (top. location! = Self. Location)

Top. Location = self. location;

// --> </SCRIPT>

10. <NoScript> <IFRAME src = *. html> </iframe> </NoScript>Webpages cannot be saved

Layer dragged with the mouse

<Body bgcolor = "# ffffff">

<Div onmousedown = "style. cursor = 'move '; startmove (this) "onmouseup =" style. cursor = 'auto' "style =" border: 1px solid # aaaaaa; Background-color: # eeeeee; width: 300; Height: 200; position; text-align: center; ">You can drag</Div>

<Script language = JavaScript>

Function startmove (objdiv)

{

Document. attachevent ("onmousemove", movediv );

Document. attachevent ("onmouseup", endmove );

Document. attachevent ("onselectstart", selectno );

Document ["movediv"] = objdiv;

Document ["startx"] = event. X;

Document ["starty"] = event. Y;

Document ["oldx"] = objdiv. getboundingclientrect (). Left;

Document ["Oldy"] = objdiv. getboundingclientrect (). Top;

}

Function movediv ()

{

// Try {

VaR OBJ = Document ["movediv"];

If (OBJ)

{

VaR L = Document ["oldx"]; // obj. getboundingclientrect (). left; // obj. style. left /// = 100 // (event. x-document ["startx"]);

VaR T = Document ["Oldy"]; // obj. getboundingclientrect (). top; // obj. style. top // = 100 // (event. y-document ["starty"]);

OBJ. style. Position = "absolute ";

OBJ. style. Left = L + (event. X-document ["startx"]);

OBJ. style. Top = T + (event. Y-document ["starty"]);

}

//} Catch (e) {endmove ();}

}

Function endmove ()

{

Document. detachevent ("onmousemove", movediv );

Document. detachevent ("onmouseup", endmove );

Document. detachevent ("onselectstart", selectno );

Document ["movediv"] = NULL;

Document ["startx"] = NULL;

Document ["starty"] = NULL;

}

Function selectno ()

{Return false ;}

</SCRIPT>

</Body>

/*Asynchronous and Dynamic Webpage LoadingXMLData*/

//Practical Use Changes

Function getxml (objcontainer, ID ){

VaR XMLHTTP = new activexobject ("Microsoft. XMLHTTP ")

Objcontainer. innerhtml = statexml (config. Loading)

Objcontainer. Send = "true"

XMLHTTP. onreadystatechange = function (){

If (XMLHTTP. readystate = 4 ){

If (XMLHTTP. Status = 200 ){

VaR xmldoc = XMLHTTP. responsexml

If(xmldoc.doc umentelement. haschildnodes ())

Objcontainer. innerhtml = xmldoc. transformnode (invalid DOC)

Else

Objcontainer. innerhtml = statexml (config. Loading)

}

Else

Objcontainer. innerhtml = statexml (config. unavaible)

}

}

XMLHTTP. Open ("get", config. Service + '? Id = '+ ID +' & TEM '+ math. Random (), true)

XMLHTTP. Send ()

}

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.