Hi,
One of my code behind file is sending some boolean value (read from the data base) to the corresponding.aspx file. I want to change the css style class of the container division based on this boolean value. I tried to do it the following way,
code behind file:
protected void Page_Load(object sender, EventArgs e)
{
Result.InnerText = "false"; //In real scenario, this is retrieved from a db
}
aspx file:
<form id="form1" runat="server">
<% if (Result.InnerText == "true") { Result.Style["Color"] = "#000000"; } else { Result.Style["Color"] = "#ff0000"; } %>
<div id="Result" runat="server">
</div>
</form>
Its seems to be working properly, but I am not satisfied with this snippet. Is this the way to do it?? I am doing it properly ???
UPDATE:
Are there any other way to do this ? If so which is the better one ? Note: I must be able to change the css class name (applied to the division) whenever required