Click here to Skip to main content
15,908,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a aspx page and this page inherits the ascx page. i want to hide the td element of ascx page from .aspx page. how can i do that please reply as soon as possible


thanks

happy coding
Posted
Updated 20-Feb-13 22:30pm
v2

To access an element in your asp.net code, you must have runat="server" set for that element.
In your case, I would suggest you wrap the HTML whose display property you want to change in a span and add runat server tag to it. So your HTML will be something like:
XML
<td>
    <span id="spnUsercontrolHtml" runat="server">
        <!--your user control html... or whatever html/text here -->
    </span>
</td>


You can access spnUsercontrolHtml at server side and you can set it's visibility or style to false/none.
C#
spnUsercontrolHtml.Visible = false;
spnUsercontrolHtml.Style.Add(HtmlTextWriterStyle.Display, "none");


Hope this helps!
 
Share this answer
 
v2
Comments
bishnu karki 21-Feb-13 5:09am    
<td style="width: 8%; font-weight: bold" align="center" id="tdProductionHeader" runat="server">
PRINTING PER UNIT
</td>

there is already runat="server" but still i cannot hide the td
i did like this

bManage_CONTRACTS_UserControls_MediaGrid_AllianceMedia MediaGrid_AllianceMedia = (bManage_CONTRACTS_UserControls_MediaGrid_AllianceMedia)Page.LoadControl("../Contracts/UserControls/MediaGrid_AllianceMedia.ascx");

MediaGrid_AllianceMedia.FindControl("tdProductionHeader").Visible = false;

please reply
Ankur\m/ 22-Feb-13 0:03am    
Are you able to get the right control? Put a debugger and check if this is a valid control - MediaGrid_AllianceMedia.FindControl("tdProductionHeader")
If it is, the next step is to typecast it into control type. then you can access all it's properties.
Do the way I suggested. Wrap the content into a span and you can easily get, typecast and hide it.
 
Share this answer
 
Please see below syntax If control is textbox
TextBox myTextBox = userControl.FindControl("YourTextBox") as TextBox;
myTextBox.Visible=false;
 
Share this answer
 
Comments
bishnu karki 21-Feb-13 4:36am    
i want to hide the td element of the ascx page from aspx page. how can i do that please reply soon.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900