I am trying to change font size of label controls, but what I tried is not working.
HTML
<asp:Label ID="LabelName" runat="server" Text="Name"></asp:Label>
<asp:Label ID="LabelDate" runat="server" Text="Date"></asp:Label>
<div class="input-group">
<asp:DropDownList ID="FontSize" runat="server" CssClass="form-control" onchange="ChangeSize(this.value)"></asp:DropDownList>
</div>
JavaScript
<script type="text/javascript">
function ChangeSize(FontValue) {
document.getElementById("LabelName").style.FontSize = ValueFont;
document.getElementById("Labeldate").style.FontSize = ValueFont;
}
</script>
C#
The DropDownList control for font size is populated from Database
private void FetchFontSize()
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlCommand cmd = new SqlCommand("SELECT fontsize FROM FontTable", con))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
FontSize.DataSource = cmd.ExecuteReader();
FontSize.DataTextField = "fontsize";
FontSize.DataValueField = "fontsize";
FontSize.DataBind();
con.Close();
FontSize.Items.Insert(0, new ListItem("Size", " "));
FontSize.Items[0].Selected = true;
FontSize.Items[0].Attributes["disabled"] = "disabled";
}
}
}