Reputation: 809
I am trying ot use C# / ASP.NET
to pull a date from an Oracle Database
and if the date is later than a certain day, hide a section of a form. The problem is, normally when I have been using a div runat=server
to call from within ASP.NET
I can just say CONTROLID.Visible=true
and it works.
For some reason this form when run is prepending "mainContent_", the ContentPlaceHolderID
of the form plus an underscore, to any DIV's run at the server. This means my CONTROLID is then renamed to mainContent_CONTROLID
and is not shown.
How do you prevent this?
Upvotes: 2
Views: 342
Reputation: 21117
<div id="yourControlId" runat="server" ClientIDMode="Static"></div>
Upvotes: 1
Reputation: 43087
This is because the PlaceHolder
is an INamingContainer
. ASP.NET, by default, builds a unique client ID based on the naming container hierarchy.
Use control.ClientID
in your client script or change the ClientIDMode
to Static
.
Upvotes: 4