Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

div server control - set visibility

Posted on 2006-07-13
5
Medium Priority
?
1,220 Views
Last Modified: 2012-06-22
I have created a master page for my site and have a div server contorl:

<div id="leftcolumn" runat="server">'

I want to be able to set the visibility of this control for my different pages.

Whenever the a page renders, the source shows:

<div id="ct100_leftcolumn">

So, first off, the styles for the control don't apply because the id is different than what I specified when the page renders.  Secondly, I can't set the visibility for the control in the code-behind.

What is the appropriate way to handle this?

0
Comment
Question by:-Dman100-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Expert Comment

by:vinodhsomasekharan
ID: 17106028
Hai,

From serverside u can Remove/set the visibility of the div control by
myDiv.Style.Add("visibility", "hidden")
myDiv.Style.Add("visibility", "visible")

Hope this helps

Regards
Vinodh

0
 
LVL 10

Expert Comment

by:orbulat
ID: 17106041
the source shows "ct100_leftcolumn" because it's inside another control like user control or place holder / datagrid ..etc....

of u can update your javascript function to reference the id "ct100_leftcolumn"

as vinodh said, u can use leftcolumn.Style.Add("xxxx","xxxxx"); or leftcolumn.Attributes.Add("xxxx","xxxxx");
and remove leftcolumn.Attributes.Remove("xxxx");
0
 

Author Comment

by:-Dman100-
ID: 17106134
Would a master page be considered another control?  The div server control sits inside the master page.

Here is how my master page looks:

<%@ Master Language="C#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
 <title>Company Title</title>
 <link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="topnav">
<table cellSpacing="0" cellPadding="0" border="0">
<colgroup span="1" align="left" width="50%">
</colgroup>
<colgroup span="1" align="right" width="50%">
</colgroup>
<tr>
<td>&nbsp;</td>
<td>
<form style="MARGIN: 0px" name="frmSearch" action="" method="post">
Search <input type="text" size="25" name="txtQuery"> <A href="javascript:document.frmSearch.submit()">
<IMG src="images/go.gif" align="absMiddle" border="0"></A>
</form>
</td>
</tr>
</table>
</div>
<div id="header">
<table border="0" cellpadding="0" cellspacing="0">
<colgroup width="25%" bgcolor="#ffffff" span="1">
</colgroup>
<colgroup width="75%" span="1">
</colgroup>
<tr>
<td>
<img src="images/CL_4C_75px.gif" alt="CompassLearning: Better Technology for Improved Student Achievement">
</td>
<td class="hdrgradient">&nbsp;</td>
</tr>
</table>
</div>
<div id="main">
<div id="leftcolumn" runat="server">This is the left column navigation bar</div>
<div id="rightcolumn" runat="server">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
<div id="footer">This is where the footer goes</div>
</div>
</body>
</html>


So, when I create new pages and add the MasterPageFile in the Page directive, I want to be able to control the visibility of the <div id="leftcolumn" runat="server"> in the MasterPageFile and turn on or off the visibility of the div server control.
0
 

Author Comment

by:-Dman100-
ID: 17106163
As a follow-up, I tried the following in the code-behind for the pages I want to turn off the visibility of the leftcolumn div:

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        leftcolumn.Style.Add("visibility", "hidden");
    }
}

Which gave me the error: 'leftcolumn does not exist in the current context'
0
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 2000 total points
ID: 17106410
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question