patterncsharpMinor
Email confirmation model
Viewed 0 times
confirmationmodelemail
Problem
Email
Re-enter EmailI'm thinking that I want a model so that I can have this partial page strongly typed. But what a lame model....
It would look like this, and if this is a good Idea, what should I name this model?
public class ConfirmEmailModel?????
{
[Required]
[Display(Name = "Email",ResourceType=typeof(mvc3test.Resources.Common))]
public string Email{ get; set; }
[Display(Name = "Confirm Email")]
[Compare("Email", ErrorMessage = "no match.")]
public string ConfirmEmail{ get; set; }
}Solution
I don't know ASP.NET, but isn't this the job of a view helper? Or an "HTML Helper" as they put it.
An HTML Helper is just a method that returns a string. The string can represent any type of content that you want. For example, you can use HTML Helpers to render standard HTML tags like HTML and tags. You also can use HTML Helpers to render more complex content such as a tab strip or an HTML table of database data.
I say don't create a "view model," instead create a view helper.
That is straight from: http://www.asp.net/mvc/tutorials/older-versions/views/creating-custom-html-helpers-cs
An HTML Helper is just a method that returns a string. The string can represent any type of content that you want. For example, you can use HTML Helpers to render standard HTML tags like HTML and tags. You also can use HTML Helpers to render more complex content such as a tab strip or an HTML table of database data.
I say don't create a "view model," instead create a view helper.
That is straight from: http://www.asp.net/mvc/tutorials/older-versions/views/creating-custom-html-helpers-cs
Context
StackExchange Code Review Q#2768, answer score: 2
Revisions (0)
No revisions yet.