Your C# code will treat your HTML as a plain string. If you want to access an element from your form in code behind then you have to set
runat="server"
attribute for that element and assign a unique
ID
to it so the server can access it. For example:
ASPX:
<div id="divmainmenu" runat="server" />
Then in your C# code, you can reference the element by its ID and set the style
Controls.Attributes.Add
method:
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostback){
divmainmenu.Attributes.Add("style", "display:block;");
}
}
Otherwise, you can handle that at the client-side using JavaScript or jQuery as already suggested.