Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My div is not showing aftr certain events. I made it runat server and set its visibility true or false using its ID on server side but its not happening.
At runtime in view source this DIV shown as visibility:none
any suggestion would be helpful.

ASPX code

XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                   <ContentTemplate>
                       <div id="calc_rebuild_cost" runat="server">
                           <vam:ImageButton ID="btnRebuildCalc" runat="server" CssClass="LeftPaddedButton" AlternateText="Calculate Rebuild Cost"
                               ImageUrl="~/img/Images/calc_rebuild_cost.png" OnClick="btnRebuildCalc_Click" />
                       </div>
                   </ContentTemplate>
                   <Triggers>
                       <asp:AsyncPostBackTrigger ControlID="btnRebuildCalc" EventName="Click" />
                   </Triggers>
               </asp:UpdatePanel>



Code behind:

C#
if (!rebuild_cost.Visible)
           {
               //display the calculate button
               calc_rebuild_cost.Visible = true;
               //calc_rebuild_cost.Style.Add("display", "block");
           }
           else
           {   calc_rebuild_cost.Visible =false ;
           // calc_rebuild_cost.Style.Add("display", "none");
        }
Posted
Comments
Deviprasad Das 15-Jan-14 7:24am    
You did a browser view source?
chandrayog.2 15-Jan-14 7:38am    
sorry i mean browser debug on chrome.
Karthik_Mahalingam 15-Jan-14 7:30am    
not clear, during on load is it visible ??
chandrayog.2 15-Jan-14 7:36am    
actually on load it is not visible but after certain conditions it should be visible but that is not happening
Karthik_Mahalingam 15-Jan-14 7:41am    
debug and check the condition..
some where it is wrong..
post your full code..

Server side .Visible is not the same as the client side visibilty attribute. When you set .Visible =false on the server side the control is not even sent to the client at all, it won't even be in the HTML.

To set the client side visibilty property from server side you can do like this:
C#
txt1.Style[HtmlTextWriterStyle.Visibility] = value;
 
Share this answer
 
Hello,
I think you have to use update() method of UpdatePanel after you change the visibility of your div.
http://msdn.microsoft.com/fr-fr/library/system.web.ui.updatepanel.update.aspx[^]
 
Share this answer
 
we can not use html control id in code behind instead of div use panel which is server side control
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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