
http://csharp-video-tutorials.blogspo...
Link for csharp, asp.net, ado.net, dotnet basics, mvc and sql server video tutorial playlists
https://www.youtube.com/user/kudvenka...
Regular expression attribute is great for pattern matching validation. Let's understand using Regular expression attribute with an
example. We will be continuing with the example that we started in Part 80 of the asp.net mvc tutorial.
Here is the requirement for validating Name property
1. Name can contain first and last name with a single space.
2. Last name is optional. If last name is not present, then there shouldn't be any space after the first name.
3. Only upper and lower case alphabets are allowed.
This requirement can be very easily met using RegularExpression attribute. In Employee.cs class file, decorate Name property with
RegularExpression attribute.
[RegularExpression(@"^(([A-za-z]+[\s]{1}[A-za-z]+)|([A-Za-z]+))$")]
public string Name { get; set; }
Notice that, we are passing regular expression string to the attribute constructor. Regular expressions are great for pattern
matching and ensures that, the value for name property is in the format that we want. Also, notice that we are using a verbatim
literal(@ symbol) string, as we don't want escape sequences to be processed. We discussed verbatim literal in Part 4 of C# tutorial.
Understanding and writing regular expressions is beyond the scope of this video. If you are interested in learning to write regular
expressions, here is a link from MSDN
http://msdn.microsoft.com/en-us/libra...
The following website is very helpful, for writing and testing regular expressions. This website also contains commonly used
regular expressions. Infact, I have picked up the regular expression for validating Name property from here.
http://gskinner.com/RegExr/
Let's discuss another example of using validation attribute. A valid internet email address should have an @ and a DOT symbol in it.
To match this pattern, use the following regular expression.
^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$
In Employee.cs class file, decorate Email property with RegularExpression attribute as shown below.
[RegularExpression(@"^[\w-\._\+%]+@(?:[\w-]+\.)+[\w]{2,6}$", ErrorMessage = "Please enter a valid email address")]
public string Email { get; set; }
asp.net core docker Part 83 RegularExpression attribute in asp net mvc | |
125 Likes | 125 Dislikes |
54,549 views views | 524K followers |
Education | Upload TimePublished on 22 Aug 2013 |
Related keywords
wcf vs web api,ado.net core,sql server management studio,webkinz,webadvisor,craigslist nj,wcf one piece,asp.net core 3,ajax players,weber grill parts,webtoon,tutorials by hugo,csharp corner,mvc design pattern,asp.net machine account,servers for minecraft,asp.net core dependency injection,ado.net tutorial,services angular,attributes disk clear readonly,ajax ontario,asp.net mvc tutorial,asp.net cos'è,csharp assembly,tutorialspoint python,sql join,services briefcase,asp.net core web api,data entry,ajax jquery,wccftech,craigslist ny,data warehouse,asp.net zero,csharp foreach,server memes,sql date format,services online,chase,serverless architecture,server resume,data science,wcf c#,server books,tutorialspoint javascript,mvcc connect,ado.net mysql,services technologies gps,data scientist,attribute changer,ajax deadpool,server jobs,cvs,website,mvc tutorial,costco hours,wcf service application,tutorialspoint spring,serverless,wcf soap,wcf cat,cool math games,wcf test client,services & training hse colombia sas,servicestack,citibank,asp.net core identity,sql union,ajax parking,sql database,asp.net core logging,mvconnect,cunyfirst,asp.net guida,wcf nba,csharp download,wcfi foundation,csharp online,wcf authentication,tutorials near me,http://asp.net,server 2019,chernobyl,ado.net descargar,web of dreams,serverminer,ajax cleaner,ado.net visual studio 2019,webassign,ado.net vs entity framework,data star trek,data lake,ado.net visual studio 2017,csharp list,sql like,asp.net mvc,asp.net core tutorial,sqlite,wcfm,ajax roster,mvc architecture,http://ado.net,asp.net core mvc,ajax soccer,server hosting,data scientist salary,wcfi,ajax dish soap,capital one,server rack,tutorialspoint html,data mining,csharp interface,craigslist,attributeerror module 'cv2.cv2' has no attribute 'face',webroot,tutorialspoint reactjs,attribute بالعربي,ajax request,wcf dragon ball,asp.net core 2.2,tutorialspoint python 3,sql developer,webster,services transmission company sas,attributeerror module 'urllib' has no attribute 'urlopen',sql group by,asp.net core signalr,services manager,mvc framework,ajax paving,mvc near me,data analysis,tutorialspoint spring boot,mvc map,csharp online compiler,asp.net download,sql between,data analyst salary,ado.net c# pdf,services tag dell,wcf 2019 nba,csharp switch,ado.net ventajas y desventajas,csharpstar,wcf tutorial,attribute معنى,tutorialspoint,ajax meaning,attributeerror module 'pip' has no attribute 'main',csharp-video-tutorials.blogspot,tutorials dojo,attribute ترجمة,central park 5,csharp string format,ado.net c#,asp.net core github,server status,ajax fc,server jobs nyc,asp.net core swagger,sql formatter,credit karma,services group,server error in '/' application,attributes provided by img tag of html are source file width/height and *,data entry jobs,services windows,asp.net core 3.0,sql injection,tutorialspoint c#,wcf ria services,calculator,ado.net entity data model,sql insert,data analytics,tutorialspoint tableau,services google play apk,attributes ترجمة,sqlyog,asp.net core 3 release date,sql server,server job description,tutorials by a,servicenow,webcam,mvc hours,attribute data,webmd symptom,csharp array,csharp enum,ajax call,asp.net core 2. guida completa per lo sviluppatore,asp.net core,server pro,server status ffxiv,cheap flights,webcrims,asp.net core hosting,services sas,tutorialspoint java,tutorialspoint java compiler,datadog,webmd,csharp to json,college football,ado.net dataset,csharp dictionary,attributeerror 'nonetype' object has no attribute 'shape',cnn,website builder,tutorialspoint sql,attributed,asp.net web api,server side rendering,weber grills,attributeerror 'str' object has no attribute 'decode',sql server 2017,tutorialspoint spark,mvc nj,data breach,ado.net oracle,asp.net core download,csharp to vb.net,webster bank,attributes,webstaurant,datacamp,tutorialsystems,ajax post,services fms publish announcement,services.msc no abre,attributeerror,ajax jersey,attributes html,csharp operator,asp.net core razor pages,server duties,asp.net core environment variables,csharp random,century 21,services consultores,services consulting,mvcsd,services.msc,mvcsc,ado.net pdf,attributes معنى,asp.net core configuration,ajax marvel,sql update,asp.net tutorial,mvc medical,ado.net entity data model visual studio 2019,wcfs international curriculum,mvc2,ado.net entity data model visual studio 2017,chase online,wcf api,costco,server jobs near me,webex,sql meaning,sql tutorial,sql commands,data universe,ado.net entity framework,ajax tavern,tutorialsteacher,ajax javascript,database,services desk,data visualization,ajax greek,csharp tutorial,mvc pattern,ado.net sql server,ado.net connection,asp.net identity,mvcu,databricks,asp.net core middleware,data analyst,wcf web service,attributes meaning,attributed to,mvc webadvisor,web store,mvcc,webmail,mvci,mvctc,
Không có nhận xét nào:
Đăng nhận xét