Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2011, 06:52 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Compile error

I get the following compile error.
Error 1 The name 'Roles' does not exist in the current context

In the ManagePhotoAlbum.aspx directory
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("Manager");
break;
}
}
 
Old May 16th, 2011, 07:07 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Yellow screen of death.

This is the error message from the yellow screen of death.

Code:
Server Error in '/Chapter 13' Application.
--------------------------------------------------------------------------------

Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0103: The name 'Roles' does not exist in the current context

Source Error:

 

Line 45:           case ListViewItemType.DataItem:
Line 46:               Button deleteButton = (Button)e.Item.FindControl("DeleteButton");
Line 47:               deleteButton.Visible = Roles.IsUserInRole("Manager");
Line 48:               break;
Line 49:       }
 

Source File: c:\Wrox Ripup\Chapter 13\ManagePhotoAlbum.aspx.cs    Line: 47 



case ListViewItemType.DataItem:
Line 46:               Button deleteButton = (Button)e.Item.FindControl("DeleteButton");
Line 47:               deleteButton.Visible = Roles.IsUserInRole("Manager");
Line 48:               break;
Line 49:       }
 
Old May 17th, 2011, 07:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Looks like you missed step 4 of the exercise on page 614.

Also, take a look at page 178 to see how to make VWD add the using statement for you.

Finally, when you post messages like these, can you please post the chapter and page number? Makes it easier for me to find stuff.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 19th, 2011, 03:28 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

Have you checked the Roles is publicly invoked in your page class. If it is a static class, then please check whether you are having the reference for your class?
__________________
Thanks in advance.

Regards,

Senthil Kumar M.





Similar Threads
Thread Thread Starter Forum Replies Last Post
compile error yogeshyl Excel VBA 0 December 12th, 2007 06:41 AM
Compile error: Syntax error: & Else without HELP Corey VB How-To 2 April 21st, 2006 03:25 PM
Compile Error: Michael Gavel BOOK: Beginning Access VBA 2 January 20th, 2004 11:36 AM
Compile Error aglatfel Access VBA 2 January 13th, 2004 04:01 PM
compile error burdickdave C# 1 October 20th, 2003 01:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.