jeg
jeg

Reputation: 61

c# - codebehind div style change not being rendered

I have a div of the form

<div id="mydiv" runat="server" style="display:none"></div>

In my code behind, I attempt to change the display to block by

mydiv.Style["display"] = "block";

When I view the source code after the piece of code above is run, the page source reflects the change (i.e. the div's display is set to block) but the visible page does not. How can I get my page to show the div?

Upvotes: 0

Views: 637

Answers (1)

Sky Fang
Sky Fang

Reputation: 1101

Where is your code mydiv.Style["display"] = "block";? I just test it in Page_Load,and in the view page,it displayed,and the code in page source is this

<div id="mydiv" style="display:block;">12345</div>

I set innerhtml to have a good view

Upvotes: 1

Related Questions