I have tried this
login_div.Style("display") = "none";
But it's not working.how can I set the display of the div to none through code behind, in aspx I have a div:
<div id="login_div" runat="server">
I have tried this
login_div.Style("display") = "none";
But it's not working.how can I set the display of the div to none through code behind, in aspx I have a div:
<div id="login_div" runat="server">
I believe this should work:
login_div.Attributes.Add("style","display:none");
Style is a collection of name-value pairs so you would set it as:
login_div.Style["display"] = "none";
(Square brackets, not curved).
Since this is a login div, shouldn't the default be to NOT display it. I am going to go ahead and assume then you want to display it then via javascript.
<div id="login" style="display:none;">Content</div>
Then using jQuery:
<script type="javascript">$('#login').show();</script>
Another method you might consider is something like this:
<div id="login" style="display:<%=SetDisplay() %>">Content</div>
And the SetDisplay() method output "none" or "block"
if(displayit){
login_div.Style("display")="inline"; //the default display mode
}else{
login_div.Style("display")="none";
}
Adding this code into Page_Load
should work. (if doing it at Page_Init you'll have to contend with viewstate changing what you put in it)
try this
<div id="login_div" runat="server">
and on the code behind.
login_div.Style.Add("display", "none");