<script type="text/javascript" language="javascript">
var enumTabInfo = {
BasicInformation: 1,
SkillDetail: 2,
EducationDetail: 3,
ProjectDetail: 4,
CompanyDetail: 5
}
$(document).ready(function(){
$("div.UserTab").Hide();
var intTabNo = Number($("#<%= hdnCurrentTab.ClientID %>").val());
switch (intTabNo) {
case enumPageStep.BasicInformation:
$("#divBasicInformation").show();
break;
case enumPageStep.SkillDetail:
$("#divSkillDetail").show();
break;
case enumPageStep.EducationDetail:
$("#divEducationDetail").show();
break;
case enumPageStep.ProjectDetail:
$("#divProjectDetail").show();
break;
case enumPageStep.CompanyDetail:
$("#divCompanyDetail").show();
break;
}
});
</script>
Showing posts with label Enum. Show all posts
Showing posts with label Enum. Show all posts
Sunday, July 11, 2010
Using Enum in Javascript
Saturday, July 10, 2010
Enum Extention
Enum Extention :
Get Enum Data :
public static class EnumExtention
{
public static Dictionary<int, string> GetEnumData(this Type EnumType)
{
Dictionary<int, string> objEnumList = new Dictionary<int, string>();
if (EnumType != null && EnumType.IsEnum)
{
foreach (int intCount in Enum.GetValues(EnumType))
{
objEnumList.Add(intCount, Enum.GetName(EnumType, intCount).ToString().Replace("_", " "));
}
}
return objEnumList;
}
}
Output :
private enum enumUserType
{
Admin,
Sales_Department,
Purchase_Department,
Guest
}
protected void Page_Load(object sender, EventArgs e)
{
ddlUserType.DataSource = typeof(enumUserType).GetEnumData();
ddlUserType.DataTextField = "Value";
ddlUserType.DataValueField = "Key";
ddlUserType.DataBind();
}
<select name="ddlUserType" id="ddlUserType">
<option value="1">Admin</option>
<option value="2">Sales Department</option>
<option value="3">Purchase Department</option>
<option value="4">Guest</option>
</select>
Labels:
Database,
Enum,
Enum Extention,
SQL,
SQL 2008
Subscribe to:
Comments (Atom)