Because Microsoft AJAX Library has greatly expanded JavaScript,
Enumeration is also a common function,
This is to explore the JavaScript enumeration function.
Because the example is simple,
So it's okay to directly look at the HTML Tag.
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Asp: ScriptManager ID = "ScriptManager1" runat = "server">
</Asp: ScriptManager>
<Script language = "javascript" type = "text/javascript">
Type. registerNamespace ("BaoBeiMe ");
// Register an enumeration
BaoBeiMe. EnumDepartment = function (){
}
BaoBeiMe. EnumDepartment. prototype = {
One: "Information Department ",
Two: "Business Department ",
Three: "Finance Department ",
Four: "R & D department"
}
BaoBeiMe. EnumDepartment. registerEnum ("BaoBeiMe. EnumDepartment ");
Function Button1_onclick (){
Var enumDepartment = new BaoBeiMe. EnumDepartment ();
Var lblMsg = $ get ('<% = lblMsg. ClientID %> ');
LblMsg. innerText = "One is" + enumDepartment. One + "," +
"Two is" + enumDepartment. Two + "," +
"Three is" + enumDepartment. Three + "," +
"Four is" + enumDepartment. Four + "";
}
</Script>
<Div>
<Input id = "Button1" type = "button" value = "retrieve the enumerated value"
Onclick = "return Button1_onclick ()"/> <br/>
<Br/>
<Asp: Label ID = "lblMsg" runat = "server" Text = ""> </asp: Label>
</Div>
</Form>
</Body>
</Html>
Result