|
-
Jun 24th, 2011, 03:29 AM
#1
[RESOLVED] The name "Exclude" does not exist in current context
Hi,
Why am I receiving the error: The name "Exclude" does not exist in current context when using the following code?
asp Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace MvcMusicStore.Models
{
[MetadataType(typeof(AlbumMetaData))]
public partial class Album
{
//Validation rules for Album class
[Bind(Exclude == "AlbumID")]
public class AlbumMetaData
{
[ScaffoldColumn(false)]
public object AlbumId {get; set;}
[DisplayName("Genre")]
public object GenreId { get; set; }
[DisplayName("Artist")]
public object ArtistId { get; set; }
[Required(ErrorMessage = "An album title is required")]
[StringLength(160)]
public object Title { get; set; }
[DisplayName("Album Art URL")]
[StringLength(1024)]
public object AlbumArtURL { get; set; }
[Required(ErrorMessage = "Price is required")]
[Range(0.01, 100.00, ErrorMessage = "Price must be between 0.01 and 100.00")]
public object Price { get; set; }
}
}
}
Thanks,
Nightwalker
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jun 24th, 2011, 04:20 AM
#2
Re: The name "Exclude" does not exist in current context
Eh, I haven't tried this in VS2010, but are you sure the syntax is
Code:
[Bind(Exclude == "AlbumID")]
and not
Code:
[Bind(Exclude = "AlbumID")]
?
.
-
Jun 24th, 2011, 07:18 AM
#3
Re: The name "Exclude" does not exist in current context
== is a comparison equals, while = is the assignment operator... but since you're in an attribute markup, I'm not sure C# rules apply....
And this thread would seem to back that up...
http://stackoverflow.com/questions/6...lude-id-in-mvc
-tg
-
Jun 24th, 2011, 06:43 PM
#4
Re: The name "Exclude" does not exist in current context
 Originally Posted by honeybee
Eh, I haven't tried this in VS2010, but are you sure the syntax is
Thanks, for pointing out the oversight! Checking my notes again it is "=" and not "==" I am suppose to use.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jun 30th, 2011, 07:42 PM
#5
Re: The name "Exclude" does not exist in current context
 Originally Posted by techgnome
== is a comparison equals, while = is the assignment operator... but since you're in an attribute markup, I'm not sure C# rules apply....
C# rules do apply, the value "AlbumID" is being assigned to the property "Exclude" on the Bind attribute.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|