View Single Post
  #1 (permalink)  
Old December 31st, 2010, 10:22 AM
skachy skachy is offline
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 16 - Try it Out Checking Roles with IsUserInRole at Runtime

Hi,
I have completed this excersie, but i cannot see the results as expected.

It does not display the delete buttom under the pictures within the album.
I am signed in as a Manager role. When I click on Edit Album link. i see the fields where i can upload new pic in the album , and it does not display any existing pics.

Here is my code in Default.aspx in PhotoAlbums Folder

Code:
protected void ListView1_DataBound(object sender, EventArgs e)
    {
      if (!string.IsNullOrEmpty(DropDownList1.SelectedValue))
      {
        EditLink.NavigateUrl = string.Format("~/ManagePhotoAlbum.aspx?PhotAlbumId={0}", DropDownList1.SelectedValue);
        EditLink.Visible = true;
      }
      else
      {
        EditLink.Visible = false;
      }

Here is the code in ManagePhotAlbum.aspx
I debugged this page by putting a break point on switch statement, and saw that it does not go pass the switch statement, that means the deletebutton visible is not executed at all.

Code:
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
  {
    switch (e.Item.ItemType)
    {
      case ListViewItemType.DataItem:
        Button deleteButton = (Button)e.Item.FindControl("DeleteButton");
        deleteButton.Visible = Roles.IsUserInRole("Managers");
        break;
    }
  }
Thanks for your help in advance
Suhail
Reply With Quote