Hello guys, I'd like to clarify a few things with IDs and classes. As I've learned so far, ASP.NET adds its own id and overwrite the previous one, if there was any. Let's just take a recent example, the panel I added in my previous thread:
<asp:Panel ID="ThankYouPanel" runat="server">
<div class="thankYouMsg" id="thankYouMsg" runat="server">
<h2>Thank you for your feedback.</h2>
</div>
</asp:Panel>
OK, so I want this panel to be hidden when the page load. Glossing over the fact that it could be easily done in c# with
protected void Page_Load(object sender, EventArgs e)
{
ThankYouPanel.Visible = false;//hide thank you message
...
}
(in fact let's comment that out), I thought I'd like to do it in the CSS, because undoubtly as I progress with ASP.NET there will be times when that's necessary. So, how do I do it then?! If I check firebug the id of the panel (which is now rendered as a div) isn't in fact ThankYouPanel
anymore but it's now ctl00_contentPlaceholder_ThankYouPanel
. So, what do I do? Can the panel have a class? Do I target that id? What really confuse me the most though, is the fact that, even though the id is now different I can still use it in the code behind...
So I can do this ThankYouPanel.Visible = false;
using the original id, which as we know, is now gone...why?! Is that because the id gets changed after compilation and the code behind somehow runs before?! WOuld be grateful if somebody could explain it to me