Solved

div server control - set visibility

Posted on 2006-07-13
5
1,188 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 500 total points
ID: 17106410
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now