Results 1 to 5 of 5

Thread: [RESOLVED] The name "Exclude" does not exist in current context

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [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:
    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.Web;
    5. using System.ComponentModel;
    6. using System.ComponentModel.DataAnnotations;
    7. using System.Web.Mvc;
    8.  
    9.  
    10. namespace MvcMusicStore.Models
    11. {
    12.     [MetadataType(typeof(AlbumMetaData))]
    13.     public partial class Album
    14.     {
    15.         //Validation rules for Album class
    16.         [Bind(Exclude == "AlbumID")]
    17.         public class AlbumMetaData
    18.         {
    19.             [ScaffoldColumn(false)]
    20.             public object AlbumId {get; set;}
    21.             [DisplayName("Genre")]
    22.             public object GenreId { get; set; }
    23.             [DisplayName("Artist")]
    24.             public object ArtistId { get; set; }
    25.             [Required(ErrorMessage = "An album title is required")]
    26.             [StringLength(160)]
    27.             public object Title { get; set; }
    28.             [DisplayName("Album Art URL")]
    29.             [StringLength(1024)]
    30.             public object AlbumArtURL { get; set; }
    31.             [Required(ErrorMessage = "Price is required")]
    32.             [Range(0.01, 100.00, ErrorMessage = "Price must be between 0.01 and 100.00")]
    33.             public object Price { get; set; }
    34.         }
    35.     }
    36. }

    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

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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")]
    ?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: The name "Exclude" does not exist in current context

    Quote Originally Posted by honeybee View Post
    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

  5. #5
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: The name "Exclude" does not exist in current context

    Quote Originally Posted by techgnome View Post
    == 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
  •  



Click Here to Expand Forum to Full Width