How to implement the function of DOS in Data Enter the Ranking in DOS in the web page developed by VS.NETC# Builder

zhaozj2021-02-11  194

How to implement the function of DOS in Data Enter the Ranking in DOS in the web page developed by VS.NET/C# Builder

Beijing Coal Scientific Research Institute Economics and Information Research Institute Ding Bao

In the DOS era, we are used to entry the data entry to the next line after entering the line after entering a line of data. The glory of the past DOS has become the past, and today, more friendly and easy-to-use GUI graphical operation interface Windows has entered our daily life.

In 1996, the emergence of Windows95 was a great revolution in the history of software. Windows is a graphical operating system developed by Microsoft. It has overcome some of the difficulties in DOS, so that the computer is more close to people, as long as you gently click the mouse, the computer will complete a action. At the same time, Windows also changed the way to enter the data knocker in DOS. Now we want the cursor to jump to the next line or the next input box when entering the data. You can only press the TAB button on the keyboard or click on the next input with the mouse. frame. This change has no big impact on the computer users who have not been exposed to the DOS operating system, but the computer users who turn over from DOS are a chicken rib; especially our data entry, in the DOS era, it is used to entry Tap the entry of the bus to continue the entry of the data. Can you care about these old users' habits is what our developers should consider.

The author has encountered such a problem in a short ago: the user requires our front desk to enter the page to provide the function of supporting the return line. Those who have been developing know that in the traditional Windows application, it is not too difficult to implement the carriage return. We can use the check-up key value by intercepting the keyboard, then make the next control in the interface (such as text). Box input box, etc.) Get this purpose to achieve the input focus. In the web page, we can also set the focus of the web control through a scripbook (JavaScript or VBScript) language.

In the web application written in traditional ASP or JSP / PHP, we usually do a JavaScript or VBScript in an incident in an onkeypress event, OnClick event or onSubmit in the control. The code captures the key value of the keyboard carriage return, then realizes the enterprise to the specified jump order, this method of drawing can only apply to the page control element very small items, once the page control element or this class file is much more This artificial way must consume great workload. Can you have a valid way to make us always? This is the content of this article to discuss. The officials are in an urgency, and I will come slowly:

Our project is developed with VB.Net, the front desk entry interface is the HTML page generated after the VB.NET program is compiled, and runs in the browser. The biggest benefit of VB.NET development is that the program code can be isolated from the interface, which is independent of each other; but the control element name in the HTML entered interface generated after the program developed by VB.NET is very difficult, though It will also have a certain naming rule. Before compiling, we are unable to learn the recorded control element name on the compilation generating page.

In this way, we have encountered a problem. Do you say that we have to realize the return of the ROM under DOS. Only open one of the ASPX files to view the element name, then press the ASP or JSP / PHP to write the corresponding JavaScript Did the VBScript code? This is obviously a faint fact; our project has hundreds of ASPX files, to open hundreds of files one by one by one by one in ASP or JSP / PHP, write JavaScript or VBScript Enter to implement code is simply anecdote. The author found the solution by checking MSDN and repeated practice.

Below I will use the JavaScript scripting language as an example to solve this problem. I have to introduce some related knowledge before writing the code; the page files browsed in the browser are in JavaScript as a document object (DOM). There is a few "big" objects in JavaScript: Window, Document, Location, Navigator, Screen, History, etc. The Window object is the parent object of Document, Location, and History objects. Focusing on the issues we have to solve, here we focus on the three objects of Document, Form, Elements, and onKeyPress events, Document Document Object: refers to the document describing the current window or the specified window object. It contains the content from to . Usage: Document (Current Window) or .document (specified window); form object: Document.Forms [] is an array that contains all forms of forms in the document; Elements object: for the form element,

.Elements is an array that contains all objects of the form; onkeyPress event is a keyboard event, which is an event that is initiated when the user presses the keys on the keyboard. Through these three major objects, cooperate with the onKeyPress event, you can complete our requirements;

Here is the final implementation code list:

VAR JumptypeArray = New Array ("Text", "Password", "Textarea", "Checkbox", "Radio",

"SELECT", "Select-One", "Select-Multiple", "File") / / Reference page to get focus element type

Var debartypeArray = New Array ("Submit", "RESET", "Button", "Checkbox", "Radio",

"SELECT", "Select-One", "Select-Multiple", "Hidden") / / Reference page needs to exclude element types

Function Instrarray (SRC, DEC)

{// Check if the given string is in the specified string array, if returned to the index number, no -1;

FOR (var i = 0; i

{

IF (src == DEC [i])

{

Return I; // Successful, return to the index number

Break;

}

}

Return -1; // Position failed, return -1

}

Function Checkcr (EVT)

{// Enter the response function

VAR EVT = (EVT)? EVT: ((Event) Event: NULL);

Var node = (est.target)? evt.target: ((est.srcelement)? evt.srcelement: null;

Var fm = document.forms [0]; // Specify the first FORM name to the first one

IF ((Evt.Keycode == 13) && (instrarray (node.type, jumptypeArray)! = - 1))

{/ {当 当 当 对 对 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组 组

{// for begin

IF (frm.elements [i] .name == node.name)

{/ / Positioning the current object

IF ((i 1)

{// Object array indexing offside judgment

IF (Instrarray (frm.elements [i 1] .type, jumptypeArray)! = - 1)

{// Determine if the current object is an entered component, an object type array: JumptypeArray

Frm.elements [i 1] .focus (); // Setting focus

IF (Instrarray (frm.elements [i 1] .type, debartypeArray) == - 1)

{// Filter Unselected text object, object type array: DebartypeArray

Frm.elements [i 1] .select (); // Select the component text content

}

}

Return false; // Prohibited submission form content

Break;

}

Else

{// submit form content

Return True;

Break;

}

}

} // end for

}

}

Document.onkeypress = Checkcr;

Quote Description: Call the above code, such as WebENTER.JS, then write on the page to implement the loany wrap: