Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

div server control - set visibility

Posted on 2006-07-13
5
Medium Priority
?
1,230 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-
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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Loops Section Overview
Suggested Courses

971 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