Accessing The StaticMenuItemStyle Collection?

Mar 28, 2011

I have a form that contains an asp:Menu control. One of the menu items is "Login" item. The way I want my application to work is when user gets to the main page, I want all the menuItems to be disabled except for the "Login" item which forces the user to login into the system. Once logged in, all the other Menu Items will become enabled.

My problem is, in my Master Page code-behind logic, I have a routine that disables all the menu items except the "Login" item. What I want to do is also change the backcolor property for each of the disabled menu items. Here is my code below:
Code:
Private Sub DisableMenu()
Try
[code]....

The Red highlighted lines of code will do what I want but it also changes the color of the "Login" menu item which I don't want.

View 3 Replies


Similar Messages:

C# - Accessing The Form Collection In An IHttpModule Causes Event Handler Not To Get Called On Default Page

Mar 18, 2011

I've created a simple sample site to demonstrate the issue. In it, I have a Default.aspx Page that has a button on it:

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p><asp:Button OnClick="ButtonClick" Text="Button" runat="server" />
</p>
<asp:Label ID="output" runat="server" />
</asp:Content>

The code behind just sets the label text on the button click:

protected void ButtonClick(object sender, EventArgs e)
{
output.Text = "Button Click!!";
}

I then have an IHttpModule that gets called for every request:

[code].....

And now it's broken again! So to make a long story short, just by accessing the Form collection on the request in the IHttpModule, I somehow screw up the PostBack, and the event never gets fired.

View 2 Replies

Forms Data Controls :: Bind A Collection Within A Collection To A Gridview?

Jul 26, 2010

I have a list of objects that I want to bind to a gridview. Creating that list and binding it works fine for most of the public properties in that list.

There are some objects contained in each of those objects... for instance there is an Address object.

object.Address.Line1;

object.Address.Line2;

When I bind this to my gridview, I have no issues with stuff like object.DateRegistered, but how can I access things like object.Address.WhatEverProperty? I always get this error:

"A field or property with the name 'xxx.xxxx' was not found on the selected data source."

View 7 Replies

Web Forms :: How To Use Collection Class For Collection Of Data

Mar 31, 2010

I want to know that how i use the collection class for storing some data and save it letter in the data base.

View 4 Replies

Add Controls To A Collection And Update From Collection?

Mar 25, 2011

I have an ASP.NET app with lots of textboxes all over the page that need updating at various points through program execution.

These textboxes actually belong to a certain class, so for easy updating I thought I could create a Dictionary(Of string, object) and add the control.ID and the control to it and then for updating do something like this:

(in case of updating textbox.text):

[code]....

However the text property of the textbox does not actually get updated. I'm mainly trying to avoid having to manually do textbox.text = somestring for each one of my textboxes every time I have to update them.

View 3 Replies

Does The Request.Cookies Collection Get Copied To The Response.Cookies Collection

Apr 1, 2011

I know that if I have set a cookie on a previous request, it will show up in my Request.Cookies collection. I want to update my existing Cookie. Are the cookies from my Request.Cookies collection already copied to my Response.Cookies collection? Do I need to add a new cookie with the same key using Response.Cookies.Add(), or do I need to use Response.Cookies.Set()?

View 1 Replies

HttpHandlers / Modules :: Hanging Request.Form Collection Values / Request.Form Collection Is Readonly

Jun 20, 2010

I'm using HttpModule to capture requests to the web server. Before processing the page I'd like to check the values contained in some keys of the Request.Form collection and according to some logic change if necessary. I'd like to do this when BeginRequest event is fired. The problem is that the Request.Form collection is readonly.

View 4 Replies

List Collection That Contain A List Of Dictionary Collection - How To Use It

Feb 1, 2011

List<Dictionary <string,object>> I am reading about the list and collection, If possible, what are the different ways that I can utilize the list of dictionary collections..... gives me different examples or areas where I can use it.

View 3 Replies

Collection Of Property=>Value?

Jul 15, 2010

I would like to create a collection of key, value pairs in C# where the key is a property of an ASP.net control (e.g. ID) and the value is the value of that property. I would like to do this so I may later iterate through the collection and see if a given control has the properties in my collection (and the values of the properties in the control match the values defined in my collection). Any suggestions as to the best way to do this? Pseudo-code example:

Properties[] = new Properties[] {new Property(){name="ID",value="TestControl1"}, new Property(){name = "Text",value="Type text here"}}
private bool controlContainsProperties(Control control){
foreach(Property Property in Properties[])
{
if((control does not contain property) || (control property value != Property.Value))
return false;
}
return true;
}

View 2 Replies

Collection Contains - Title Don't Exist

Jan 21, 2010

I got this situation where I got a ICollection and I need to see if there is a object containing a title in it. If the title don't exist i can go ahead and shave the new object.

How can i do this? note i am already working with a for each loop on the titles..

[Code]....

View 2 Replies

MVC :: Sending The Whole Collection To View?

Mar 7, 2011

mvc-ers in the Model i have a collection of Employees (EMPLOYEE_ID,
FIRST_NAME,
LAST_NAME,
MOBILE)

and i want to send particular fields from it to the view so in the Controller i write this code

[Code]....

how can i retrieve the collection in the view, should i create a class contains (e.EMPLOYEE_ID, Employee_Name)
and cast ViewData["Employees"] to it, or there is a trick?

View 4 Replies

C# - Bind Datagrid To Collection?

Jan 20, 2010

how do I bind a DataGrid to a collection? (e.g : List ). i used this :

Datagrid dg = new Datagrid();
dg.DataSource = myCollection;
dg.DataBind();

but after this, the Datagrid still doesn't display the data from the collection.

View 5 Replies

ADO.NET :: Insert Collection Into A SQL Table?

Mar 1, 2011

I've a collection defined in .NET. The collection contains a few hundred items.

example of the object in collection:

Tag.Name = "Tag1"
Tag.ID = "2"
Tag.Location = "Home"

and so on (a few hundred items).

I've a stored procedure to insert that data into the datatable. The logic in the sp checks first if the tag name already exists in the table.

If not, then insert.

Now I can use a loop to insert the data, but is there another way to do the same more efficient ?

View 1 Replies

MVC Bug Binding Collection Of DropDownList?

Mar 25, 2011

I have a view with 1 dropdown generated from Model property and 3 additional dropdowns that are generated from array property

[code]....

The controller method initializes AgentTypeListItems collection + sets default values for AgentType dropdown and 3 dropdowns for the collection:

[code]....

View 2 Replies

C# - How To Add An Item To A Cached Collection

Mar 29, 2011

I would like to cache a collection in the viewstate, but I wonder if there is a better way to add an item to this collection!

private List<MyClass> CachedItems
{
get { return (List<MyClass>)ViewState["CachedItems"]; }
set { ViewState["CachedItems"] = value; }
}
private void AddToCachedItems(MyClass item)
{
CachedItems = CachedItems.Concat(new[] { item }).ToList();
}

View 1 Replies

DropDownList For A Collection Not Selecting Value?

Mar 28, 2011

i'm using a strongly typed view with a custom viewmodel. this viewmodel contains a collection of books.

public IList<Books> Books { get; private set; }

i'm also passing a select-list to the view. however the DropDownListFor helper class doesn't automatically preselect the default value of the book.

@Html.DropDownListFor(m => Model.Books[i].AuthorID, Model.Author as SelectList)

everything else works, e.g. it does pass the selected value back to the controller.

i figured out a workaround by creating the select list in the viewmodel:

@Html.DropDownListFor(m => Model.Books[i].AuthorID, new SelectList(Model.AuthorList, "Value", "Text", @Model.Books[i].AuthorID.ToString()))

however i don't want to implement this workaround if there is a simpler solution. is there a way that the view can handle values from a collection?

View 2 Replies

MVC :: Populating Dropdownlist From Different Collection?

Mar 23, 2011

I'm new to MVC pattern and I have a question regarding to a dropdownlist. Actually My Data came from a collection (random string) then it displays it in a list. And yes it display, so I add a dropdownlist. And I can populate it using the same collection. My question is how can I populate the dropdownlist from different collection?

Here's my View

[Code]....

View 10 Replies

MVC :: Pass In A Collection Into A Partial?

Mar 31, 2010

In my view I have a call to Html.RenderPartial("Products", Model.Products)

But it does not like that. Products is a linq to sql relation on Category (I am using the northwind database).

View 10 Replies

MVC :: Use DisplayForModel And EditorForModel With A Collection?

May 26, 2010

How can I use DisplayForModel in a loop with a View for which I've passed a collection of objects? That is, within the loop I want to call DisplayForModel each time for the specific object (not the collection). Or does MVC not currently support this?

So I'll like to be able to do something like in the below, but this itself doesn't work.

[Code]....

View 8 Replies

ADO.NET :: Linq Collection Exists?

Aug 12, 2010

Imagine I have 3 classes (student has Marks which has subjects)

[Code]....

I got a List<Student> populated with all the student and nested collection of corresponding Marks and subjects.How do I, before binding this list to any grid, filter records to display only those students, who surely have appeared in subjects with name "X" and "Y"?I tried something like:

[Code]....

View 2 Replies

C# - Get Item From Collection By Unique ID

Apr 27, 2010

I have a collection of Contacts that inherits from CollectionBase:

public class ContactCollection : CollectionBase{
//...
}

each contact in the collection has a unique ID:

public class Contact{
public int ContactID{
get;
private set;
}
//...
}

I think what I would like to do is something like the following:

// get the contact by their unique [Contact]ID
Contact myPerson = Contact.GetContactById(15);
// get all contacts for the customer
ContactCollection contacts = customer.GetContacts();
// replaces the contact in the collection with the
// myPerson contact with the same ContactID.
contacts.ReplaceAt(myPerson);
// saves the changes to the contacts and the customer
// customer.Save();

View 3 Replies

C# - Get Url From RouteTable.Routes Collection By Key?

Oct 14, 2010

How to get url from RouteTable.Routes collection by key?

View 2 Replies

Add New Properies In ListItem Collection?

Jun 14, 2010

I am working on to create a custom control inherited by CheckboxList control. We can add items from ListItem collection editior at the design time. In this ListItem Collection editor there are 4 properties 1) Enabled 2) Selected3) Text4) valueI really need to add some new properties such as "ImageURL" and "IsClear".

View 3 Replies

Create A Collection For Users?

Oct 21, 2010

i need a collection of users

each user have name as string, ID as integer, Email as string

View 3 Replies

.net Have Circular List Collection?

Jan 5, 2010

want to create a list representing a list of valid locations on a grid. Items can only be stored in these valid locations and I want to locate the "next available" valid location. If I do this with a traditional list I have to deal with the end of list conditions. A circular list collection would make this a bit easier. Is there such a collection in .net?

View 3 Replies







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