Assigning Css Class To Masterpage Control From Contentpage In Asp

Jul 21, 2010

I have a unordered list in my master page....

<ul id="mainMenu" runat="server">
<li id="mainHome" runat="server"><a href="#" title="Home" class="home">
<span></span>Home</a></li>
<li id="mainManage" runat="server"><a href="Users.aspx" title="Manage"
class="manage"><span></span>Manage</a></li>
<li id="mainEnquiry" runat="server"><a href="account.aspx" title="Enquiry"
class="enquiry"><span></span>Enquiry</a></li>
<li id="mainReport" runat="server"><a href="EnquiryReport.aspx" title="Report"
class="report"><span></span>Report</a></li>
</ul>

From a content page i am assigning a css class to one of the list item.

HtmlGenericControl home = (HtmlGenericControl)this.Page.Master.FindControl("mainMenu").FindControl("mainManage") as HtmlGenericControl;
string cssToApply = "current";
if (null != home)
{
if (home.Attributes.ContainsKey("class"))
{
if (!home.Attributes["class"].Contains(cssToApply))
{
home.Attributes["class"] += " " + cssToApply;
}
}
else
{
home.Attributes.Add("class", cssToApply);
}
}
and my css,
#header ul li {
display:inline;
float:left;
}
#header ul a {
-x-system-font:none;
color:#FFFFFF;
display:block;
font-family:Trebuchet MS,Arial,sans-serif;
font-size:1.1em;
font-style:normal;
font-variant:normal;
font-weight:bold;
text-transform:uppercase;
text-decoration:none;
}
#header ul a {
-moz-border-radius:3px;
-webkit-border-radius:0.2em;
padding:3px 7px;
text-decoration:none;
}
#header ul a:focus, #header ul a:active, #header ul a:hover {
background-color:#829E7E;
outline-color:-moz-use-text-color;
outline-style:none;
outline-width:medium;
}
#header ul a.home {
margin:0 16px 0 17px;
}
#header ul #current a, #headermenu #current span{ /*currently selected tab*/
background-color: #BCE27F;
color:#666666;
white-space:nowrap;
}
#header ul a.manage,#header ul a.enquiry,#header ul a.report {
margin:0 14px 0 0;
}
#home #header ul a.home, #enquiry #header ul a.enquiry, #report #header ul a.report, #manage #header ul a.manage{
-moz-border-radius:3px;
-webkit-border-radius:0.2em;
background-color:#B9E27F;
color:#FFFFFF;
}

But i get the error, System.Web.UI.AttributeCollection' does not contain a definition for 'ContainsKey' and no extension method 'ContainsKey' accepting a first argument of type 'System.Web.UI.AttributeCollection' could be found (are you missing a using directive or an assembly reference?

View 1 Replies


Similar Messages:

Web Forms :: MasterPage - Setting Body Class Of ContentPage?

Aug 23, 2010

how to set the body class of a ContentPage when using master pages?

I want to set the body class so that certain elements of my page are styles differently from each other. e.g. Navigation links to so which is the current page.

View 4 Replies

Web Forms :: MasterPage Client Onload From ContentPage And Get Value From ContentPage Code Behind

Oct 24, 2010

I am trying to get value of a variable"offset" code behind of content page which is set from default.aspx through onload event from master page.But it gives null value every time. Here is my code.

Maste.aspx
---------

<head>
<asp:ContentPlaceHolder runat="server" id="Headers"> [code]....

View 10 Replies

Web Forms :: How To Find A Control From A Contentpage When Looking From The Masterpage

Oct 7, 2010

I have a FreeTextBox control on a page that has a masterpage. This FreeTextBox control is in the maincontent.

View 5 Replies

AJAX :: How To Set MasterPage Only Render ContentPage And Control Inside UpdatePanel

Mar 27, 2011

I have a DateTime in my MasterPage.aspx that is outside of UpdatePanel1. There are two Hyperlink controls inside UpadatePanel1 to navigate or to move to the other pages. Full code of MasterPage.aspx is below.

[Code]....

If the user clicks Hyperlink to navigate or move to the other page, the DateTime will change. It means that my MasterPage.aspx render the whole page when the user clicks Hyperlink. I do not want this behavior. I want my MasterPage.aspx only render the ContentPage and the
Hyperlink inside UpadtePanel1. Controls outside UpadtePanel1 like DateTime should not be rendered again. Please advise the code to achieve my example goal.

View 2 Replies

Use MasterPage's Viewstate In ContentPage?

Feb 10, 2010

Asp.net: Can we use MasterPage's viewstate in ContentPage ?

View 1 Replies

Web Forms :: How To Avoid The Refresh In MasterPage In ContentPage

Feb 13, 2010

I have a masterpage with a timer that shows server time and refreshes every second, on the content page I have a chat program with ajax, refreshes every to second to get the last messages entered.

I have a Html TextBox and a hidden Submit Button, when user write a text, and hit the enter, I check to see if this is the enter key and then submit the message,it is working perfectly in IE, but in FireFox and Opera it show the same message twice. I think the problem is the Timer, is there any way to avoid the MasterPage timer in this particular content page?

View 1 Replies

Web Forms :: Reference To LINK Tag (css) In MasterPage From ContentPage?

Apr 24, 2010

I have applied my stylesheet in my masterpage the following way:

[Code]....

In my contentpage I wish to change the stylesheet of my masterpage, but I'm not sure how to reference to it.

I've tried the following, but I can't scope to the "test".

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
test.Href = "~/CSS/AlternativeMenu";
}
</script>

View 3 Replies

Web Forms :: Refresh Menus On The MasterPage After ContentPage PostBack

Jul 15, 2010

We have a master page file in which we have a MenuControl. We are displaying some menus according to users credentials. We are handling MenuItemDataBound event inside master page for adding & removing menus.

There is user edit page{ContentPage} on which user may edit his own credentials. After saving the edited data {users credentials} by ASP.Net Button control, the MasterPage's MenuItemDataBound event doesn't fire (in case of refresh it is firing but in case of post back it is not firing).

We need to recreate/refresh MenuItems for master pages after saving the user and add/remove any nodes from Menus.

View 4 Replies

Jquery - Masterpage And ContentPage JavaScript Function Error?

Feb 27, 2011

I am using a Masterpage for my upload_photo.aspx which displays the file upload page using colorBox. However, ever since i added (code below) in the Masterpage colorBox doesn't display:

<script type="text/javascript">
$(function () {
$("#txtAutoCompleteSearch").AutoComplete("search.aspx?searchword=");

[code]...

View 1 Replies

Assigning A Background Color To A MasterPage?

May 23, 2010

Is is possible to assign a background color to a MasterPage so the entire site has the same color? I'm using VS 2008 and have tried to do this with no success.

View 1 Replies

Web Forms :: Referencing A Control In A MasterPage From A Class?

Nov 10, 2010

I have created a class within the App_Code called shared_methods.vb where I use methods that are frequently used within several pages.

I have a hyperlink control within the masterpage that i want to change the NavigateUrl depedning on what page. Just for better coding i would like to define the variable holding the hyperlink with my shared_method.vb.

I have:

Dim hl_back As HyperLink = CType(Master.FindControl("hl_master_back"), HyperLink)

This works within a page but not within shared_methods.

View 1 Replies

Web Forms :: Reusing Class Properties Invoked In Masterpage In A User Control

Feb 2, 2010

I'm working on a project that uses a master page. When the page loads I'm calling a class (which I feed and ID into) to get back certain values for a location that the user has selected. Things like town name etc.

On the home page I have a user control which has some statistics for that location too.

Is there a way that I can get the user control to pull values from the class invoked by the Master Page (which has already been fed the ID, hit the db and pulled back the values), rather than creating a new instance of the class within the user control and having to supply the ID and hit the db all over again? This is now I'm calling the class in the masterpage. I have a method "CheckForStoredLocation" that goes off and gets all the data I need.

[Code]....

View 4 Replies

Assigning Css Class To A Linkbutton When Clicked?

Aug 14, 2010

Consider i have 3 linkbuttons on a page,

<asp:LinkButton ID="LB1" runat="server" CssClass="regular" OnClick="LB1_Click">
Today</asp:LinkButton>
<asp:LinkButton ID="LB2" runat="server" CssClass="regular" OnClick="LB2_Click">
Today</asp:LinkButton>
<asp:LinkButton ID="LB3" runat="server" CssClass="regular" OnClick="LB3_Click">
Today</asp:LinkButton>

I want to highlight a linkbutton on its click with a css and then remove its css when another linkbutton is clicked (ie) i want to show active link button.

View 2 Replies

Web Forms :: Find Control In Contentpage?

Feb 27, 2010

Im having a master page which consists an user control further which consists a Label.i want to change the text of that label in content page.

View 7 Replies

Web Forms :: Accessing Control In Nested MasterPage From Parent MasterPage?

Feb 4, 2010

I have a MasterPage (MasterPage.master) with 2 child MasterPages (specialMaster.master and standardMaster.master). From the MasterPage.master I need to get at some of the controls in one of the children, specialMaster.master, say for example to hide certain
content if a session variable is not null.

View 2 Replies

Inherit Class From Page, Usercontrol, And Masterpage?

Oct 23, 2010

I have Page, MasterPage and UserControl in my project.

So I create basepage class and share some logic, then inherit from System.Web.UI.Page. My problem is I want use single basePage for any type of UI content.

View 1 Replies

Adding Content To MasterPage Header From Class

Sep 22, 2010

I was wondering if it's possible to write some code into the Header of my Master Page from within a Class?

View 5 Replies

VS 2010 - Accessing CSS Class From Nested MasterPage

Sep 4, 2011

I'm changing the CSS of my menu items during runtime to reflect which page is currently being viewed. It works fine. But, I have a nested master page that needs to change the CSS of the master page's items. How I can access the master page's menu items?

Here's the menu:

Code:
<div class="Menu" id="TopMenu" runat="server">
<ul>
<li><a href="../Default.aspx" runat="server" id="HomeButton" class="ActiveMenuButton">
<span>Home</span></a></li>

[Code] ....

I need to access the InventoryButton ID, but am unable to directly.

View 3 Replies

Security :: Automatically Assigning Roles / Standard Practice For Assigning Roles To Newly Signed-on members?

May 17, 2010

Newb question: what is the standard practice for assigning roles to newly signed-on members. Is it usually manual or is there a way of automatically assigning roles. Being completely new to this, I am confronted by the issue of my site having three different roles that new members could fall into, but am unsure about how to assign each a role. I can't imagine having to go through the process manually if I have thousands of members.

View 6 Replies

How To Access Public Properties Of MasterPage From External Class

Jun 13, 2010

Why i can't access MasterPage's public property (MessagePlaceholder) from other Class (Errors) ?Error compiler gives me is "Error 1 The type or namespace name 'MyMasterPage' could not be found (are you missing a using directive or an assembly reference?)"my master page code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MyMasterPage : System.Web.UI.MasterPage
{
public string MessagePlaceholder

[code]...

View 1 Replies

Web Forms :: MasterPage Call To Class Doesn't Work

Dec 8, 2010

I am porting my simple Role Based Auth to ASP.NET. It requires this check on each page:

[Code]....

If put in each page's OnLoad, it works fine. But when I add it to the masterpage, it doesn't work. Is there something about the ServerVariables or Session Object that would prevent using those in a masterpage? Is it an issue calling my class from a materpage?

View 1 Replies

Web Forms :: Shared Class On Masterpage And Normal Page?

Jul 21, 2010

I've created a nice menu class and used it in my MasterPage like "using My.GeneralRoutines".This class is working well and everything is fine UNTIL I want to access this same instance of that class that was created at MasterPage level on "a_page.aspx.cs" (this page is using the MasterPage like :)

[Code]...

View 8 Replies

VS 2008 Error When Assigning A Dataview To A Gridview Control?

Mar 25, 2011

I've been working on this error all day! I have a dataview created from a sqldatasource control and I'm trying to assign it to a gridview but I get Object reference not set to an instance of an object.
Code:
Try
Session("dsCustomer") = "Y"
[code]......

Can't I assign a dataview as a datasource? Or not?

View 3 Replies

C# - Assigning Non Primitive Values To User Control Properties?

Feb 2, 2011

I have built a user control that has a public property string[] foo.

Is it possible to assign this in the actual markup?

The type of project is ASP.NET webforms / web application.

Ive tried the following syntax, but it doesnt work: (It compiles but the value is never assigned).

<abc:MyControl runat="server" foo='<%# new string[]{"Hello"} %>' />

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved