Since the Microsoft AJAX Library has been significantly extended for JavaScript,
Of course, the commonly used function of enumeration has also been added.
This time we are going to discuss the enumeration function of JavaScript.
Since the example is very simple,
So it’s OK to just look at the HTML tags
Copy the code code 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: "Ministry of Information",
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="Get all enumeration values"
onclick="return Button1_onclick()" /><br />
<br />
<asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
result