I want to add a css class (fontawesome classes) to the <i>
element based on the file type which is found from the code behind.
I'm trying to achieve something like this. (so that the font changes based on the file type from code behind)
I tried to write a JS function which I thought would solve the problem.
<head>
<script type="text/javascript">
function showIcon() {
if(<%#Eval("fileType")%>=="ppt" || <%#Eval("fileType")%> =="pptx")
{
document.getElementById('icon').className = 'fa fa-file-powerpoint-o fa-3x';
}
else if(<%#Eval("fileType")%>=="doc" || <%#Eval("fileType")%> =="docx")
{
document.getElementById('icon').className = 'fa fa-file-word-o fa-3x';
}
}
</script>
</head>
<body>
<div class="col-xs-1">
<h3><td><%# Eval("count") %></td></h3>
<span>match</span>
<div id="icon"><i aria-hidden="true"></i></div>
</div>
</body>
Can someone help me to correct this. Is there any other way in which I can do this?