Asp.Net How to control, does an element exist in document?
I want to control does an element exist in document with its ID in Asp.Net project 开发者_StackOverflow中文版when page's first or postback loading.
Thansk for your helps already now.
It sounds like your hiding a section of your page on postback, i'm assuming via the controls Visible property. The problem with this approach is that the control is never rendered when Visible="False", this is probably why your javascript code throws an error.
You can use the css property Display and set its value to None, this will allow the element to render but not display. I'm not sure what your using for a container, so i'm using a panel in my example (which renders as a div).
<asp:Panel ID="pnlContainer" runat="server">
</asp:Panel>
Then instead of toggling the Visible property, you can hide the panel using the CSS display property.
pnlContainer.Style.Add("display", "none");
精彩评论