.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

User Registration, Model Validation

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

Hello everyone -

I'm working on my first real MVC application using ADO.NET Entity Data Model and am looking for some advice. I'm starting off with creating a registration page that will accept the following data:

  • Username
  • Email
  • Password
  • Password Confirmation
  • First Name
  • Last Name
  • Job Title
  • Organization

Per my database design, I have two separate models to use here: User and Profile. I'm using MetaData partial classes to add Data Annotations, for obvious reasons. My ViewModel looks like so:

    Public Class RegistrationViewModel
        Public Property User() As User
                Return _user
            End Get
            Set(ByVal value As User)
                _user = value
            End Set
        End Property
        Private _user As User

        Public Property ConfirmPassword() As String
                Return _confirmPassword
            End Get
            Set(ByVal value As String)
                _confirmPassword = value
            End Set
        End Property

        Private _confirmPassword As String

        Public Property Profile() As Profile
                Return _profile
            End Get
            Set(ByVal value As Profile)
                _profile = valu

View Complete Post

More Related Resource Links

User validation Issue in xlsx file



I am validating user from Login.xlsx file. It was working fine by validating email and password from that file. For testing i got new file same contents of file but added some more user names.

So after that when i validating the user i am getting the following error "Data type mismatch in criteria expression".

But when i replaced the new to old one it is working fine. The contens of both files are the same. So why this kind of error happened.


Extreme ASP.NET: Model Validation & Metadata in ASP.NET MVC 2


Scott Allen shows how to improve your user input validation with new features coming out in ASP.NET MVC 2 that easily allow validation on both the client and server.

Scott Allen

MSDN Magazine March 2010

Multiple forms on the same page MVC2: how to handle (including validation from model)



It should be simple; although I'm having a hard time to figure out the best way to do it. I've MVC2 pages with multiple forms on the same page having different functionalities.

What's the best way to handle this; including the MVC2 way of validation from the model?


Mining Model - Business user's view

Using BIDS, when I create a Mining model solution I can see lot's of useful utilities like Mining Model viewer, Mining Model Prediction etc that comes with lot's of graphs' etc. What would be the best approach to display these graph's to business users. Can I do this easily using SSRS/PowerPivot etc..

XML Signature xsd and Validation Error: Wildcard '##any' allows element causes the content model t

Hello,I'm trying to generate WCF client from Customer's WCF Service which has XML Signature options enabled.When trying to generate client proxy using svcutil I get following errors: Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152] Copyright (c) Microsoft Corporation. All rights reserved. Attempting to download metadata from 'http://donex:51343/WebServices /Service.svc' using WS-Metadata Exchange or DISCO. Error: There was a validation error on a schema generated during export: Source: Line: 1 Column: 13464 Validation Error: Wildcard '##any' allows element 'http://www.w3.org/2000/09/ xmldsig#:HMACOutputLength', and causes the content model to become ambiguous. A content model must be formed such that during validation of an element informati on item sequence, the particle contained directly, indirectly or implicitly ther ein with which to attempt to validate each item in the sequence in turn can be u niquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence. Error: There was a validation error on a schema generated during export: Source: Line: 1 Column: 14410 Validation Error: Wildcard '##any' allows element 'http://www.w3.org/2000/09/ xmldsig#:XPath', and cau

Access Model Validation inside Custom Model Binder.

Hello,Is it possible, inside a Custom Model Binder, to fire "something" that "says" the value is invalid so it gets handled by validation part?Basically, I am getting an exception when the value for the property is invalid.Thank You,Miguel

custom model validation

 Hi all, I am trying to wrap my head around a practical real world scenario where the out-of-the-box model validation framework in MVC2 poses some challenges. Consider the following model classes:     public class Organization    {        public int ID { get; set; }         [Required(ErrorMessage = "Work Address is a required field.")]        [DisplayName("Work Address")]        public Address WorkAddress { get; set; }         [DisplayName("Home Address")]        public Address HomeAddress { get; set; }     }     public class Address    {        [DataType(DataType.Text)]        [DisplayName("Address 1")]        [StringLength(50)]        [Required(ErrorMessage = "Address Line 1 is a required field.")]        public string Address1 { get; set; }         [DataType(DataType.Text)] &n

Sharepoint 2010 user creation in a resource forest model

Hi,  We have a setup with Exchange 2007, Sharepoint Services 3.0 - all in the same AD Domain/Forest. Now we have to install sharepoint 2010, but want to do it in a resource forest model. This 'resource forest' model will be forllowed for SharePoint 2010 only, without exchange.  So I have created a new AD domain and installed a SPT 2010 Standard Edition Server, which by itself is working. Now, I need to create Sharepoint Sites and assign user roles to it. The Users will come from the First AD Domain. I have read some blogs on this as well. I have understood the concept at high level. My questions are 1) I should be able to deploy users in resource forest model for Sharepoint 2010 only while their mailboxes continue to work in the current default way. Right ? 2) Would the existing users who are having roles in Sharepoint 3.2.0 in the first domain, be able to get roles in SPT 2010 in resource forest ? In other words they enjoy both 3.2.0 and 2010 simultaneously ? Possible ? 3) I definitely want to automate user creation on SPT 2010 using scripting because I don't see any feature like 'linked mailbox' which does this for Exchange resource forest model. I am wondering what is the best sequence to follow for user provisioning ?      i) I take the user name from the first domain - call it U1     ii) I create a user with similar name

ASP.NET MVC Model Validation

Hello. I'm trying to validate some input fields.  in this srting - The given key was not present in the dictionary.<%= Html.ValidationMessageFor(model => model[i].FirstName)%>Here some my code:<%@ Page Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master" Inherits="ModelViewPage<List<MyClass>>"%> ... <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"> </script> <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script> <% Html.EnableClientValidation(); %> <% int count = (int)ViewData["Count"]; %> <% Html.BeginForm(); %> <% for (int i = 0; i < count; i++ ) { %> <%= Html.LabelFor(model => model[i].FirstName)%> <%= Html.TextBoxFor(model => model[i].FirstName)%> <%= Html.ValidationMessageFor(model => model[i].FirstName)%> ...My class: [MetadataType(typeof(MyClass))] public class MyClass { [Required(ErrorMessage = "First Name Requered")] public string FirstName { get; set; } ... Any help in pointing me

Data Annotation not triggering the client side validation when used on an overriden model property

Hi all, This is a saga from a post that was recently answered:http://forums.asp.net/t/1598187.aspxMy main problem is the lack of client side validation when we use a child model class, the server side validation works like a charm whether you use the virtual/override solution or the new attribute on the child class with the getter and setter linking the property to the base class's one.The client side validation does not work with none of the solutions presented below.This is a sample code of the first solution: [Serializable] public class DateViewModel { ... [Display(typeof(App_GlobalResources.Messages), "Date_Year")] public virtual int? Year { get; set; } ... } [Serializable] public class BirthDateViewModel : DateViewModel { ... [Display(typeof(App_GlobalResources.Messages), "Date_Year")] [YearRange(ErrorMessageResourceType = typeof(App_GlobalResources.Messages), ErrorMessageResourceName = "Validation_Range")] public override int? Year { get; set; } ... } This is a code sample of the second solution : [Serializable] public class DateViewModel { ... [Display(typeof(App_GlobalResources.Messages), "Date_Year")] public int? Year { get; set; } ... } [Serializable] public class BirthDateViewModel : DateViewMod

User Control Validation is not working properly

In my Website I have header control (header.ascx) and footer control (footer.ascx)In header.ascx one textbox and one button is there. Textbox meant for accepting search string.In footer.ascx one textbox and one button is there. Textbox meant for accepting Email-Id.Now in validation of header.ascx I had done blank checking by JavaScript. And in validation of footer.ascx  I had done blank-checking and e-mail checking by javascript.In both the control the textbox and the button both resides under Panel control whose DefaultButton property set to the respective button ids. So that if User write write something and press ENTER key from keyboard then it should do whatever respective Button_Clicks will do.Now My problem is suppose I place the mouse cursor in footer.ascx's textbox and press the ENTER key it validates properly but after that if I place the cursor inheader.ascx's textbox and press the ENTER then it is not working. Again If I do the opposite then also first one will fire but in case of second it is not firing .......

SSIS User Defined Data Type (Alias Data Types) and OLE DB Command validation

Hello everyone, I've been having an issue with trying to run my SSIS package on a server, and it seems to be failing on the OLE DB Command step.  What we have in our SQL 2005 DB, is a User-Defined Data Type (base type char(7)) and the OLE DB Command is supposed to call a proc that passes in a value of this data type. ie:  CREATE PROCEDURE myProcedure ( @passedInFromSSIS MY_DATATYPE ) AS .... In my SSIS package, I have the type defined as DT_STR with a length of 7.  Now, when I run the package locally (via Visual Studio), the process runs with success.  However, once the package is deployed on a server and run from an application (note: it is run under a different user), the process fails on a validation step with a "Invalid Parameter Number" error. Now, if I change the input parameter in my proc to the base type of the user-defined data type, the process works again. Has anybody run into a similar issue or know what may be causing this issue?  I first suspected perhaps I needed to grant permissions on the user-defined data type (since I was able to run it under my security context, but not under the application's), however noticed that there isn't security tied to the types.  Any other thoughts?  Please let me know if you need further explanation.  Thanks!

regarding validation of user information problem


Iam new to asp.net. in my web page iam validating user information such as fname,lname,sex,add and also login (to register to website)information emailid and password . here iwant to check email adrress (availblity) and tht iam doing it fine. but when iam validating all the textbox,which are there before emailid  something like this




login details

emailid:   check (buttonto check email availiblity)


retype password:


iam using validation controls for all the text boxes , when iam using my tab to enter the values it w,l give me alll error messege until i fill it. and when i reach email textbox  and check availblity then i cant check untill i fill the password and retype password texboxes..i can only check the email availblity only when al the fields are valid . but i want to valid the emailid before i could enter password and retype password ? how to do this  pls help me out..

Collect data from a User - Validation Bug




I use the action "Collect data from a User". I add a new field of the type Choice, the next step I write two choices:




and configure it:


Default value is blank
  Display as: Radio Buttons
  uncheck Allow Fill-in choices
  uncheck Allow blank values


Click Finich button


When the task is created I need to choose among Approved or Rejected, however if it be not chosen any alternative the validation doesn't work.


If I have a field text the validation works perfectly.


Is there a bug in validation form when the field is a "Choice type" ?


Please help-me.

Login failed for user: Reason:Token-based server access validation failed with an infrastructure err



I have installed a named instance of SQL Server 2008 R2 Enterprise 64 bit on Windows Server 2008 R2 Enterprise 64 bit. The os is running as a VM ware virtual machine.

I have created an AD security group for database engine sys admins on that machine. I added my user to that group.So for example;

domainname\machinename_SQL_DBE_SysADmins is a user with SysAdmin server role permissions. User domainname\MichaelEFF is a member of this group.

When I log onto the machine as this user and run the management studio with run as administrator I cannot log into the database engine. The log shows the error:

Login failed for user: Reason:Token-based server access validation failed with an infrastructure error

I've read many posts where the MVP says that the UAC is not passing the group membership. Is this the case? If so then how will role based access ever be possible with windows authentication? How can this be resolved?




Why does Model Validation Errors steal my markup?



I have a partial view where I render, if the user has choosen an option, a button that permit the user to generate automatically a value for a certain field. Please give a look at this picture to understand what I mean.

This is achieved using the following markup on the partial view

<%= Html.LabelFor( model => model.IssueCode )%>
<br />
<% if ( Model.HasCodeGenerator ) { %>
    <%= Html.TextBoxFor( model => model.IssueCode, new { style = "width:120px;background-color:#eeeeee;border: solid 2px #dfdfdf", @readonly = "readonly" } )%>
    <% if (Model.ModelState == ModelStateEnum.Add) { %>
        <button id="codeGenerator" style="font-size: 0.7em;margin-right: 10px">Genera codice fascicolo</button>
    <% } %>
<% } else { %>
    <%= Html.TextBoxFor(model => model.IssueCode, new { style="width: 120px" })%>
<% } %>
<%= Html.ValidationMessageFor(model => model.IssueCode, "*")%>

As you can see I append always an Html.ValidationMessageFor() at the end of the input field and a ValidationSummary aut the end of the view.

When the user submits the form the fi

Login failed for user:Token-based server access validation failed with an infrastructure error


I would appreciate help with the following issue:


I have created a local group in our SQL 2008 server and added two Windows user accounts "DOMAIN\UserName"  I  then added the local group to the database and granted read only access.


The users are trying to link tables using MS Access using and ODBC connection and getting the following error.

Users are not system administrators.


Date                      6/30/2010 1:01:54 PM

Log                         SQ

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend