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.
<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
2010-1-25