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

Top 5 Contributors of the Month
Post New Web Links

hardcode list validation in MVC

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :.NET Framework
Hello guys,   I am developing asp.net mvc application...in one of the form i have field State which shold be validated server side.... state should only state values from given list, It should be two character and from list. Hardcode list that is 'AA', 'AB' and so on.. I have taken txtbox for the field of State...now how do i validate the entered value with hardcode list???   please help me how do i do that?

View Complete Post

More Related Resource Links

hardcode list validation in MVC

Hello guys,   I am developing asp.net mvc application...in one of the form i have field State which shold be validated server side.... state should only state values from given list, It should be two character and from list. Hardcode list that is 'AA', 'AB' and so on.. I have taken txtbox for the field of State...now how do i validate the entered value with hardcode list???   please help me how do i do that?

Video: Field and List Item Validation in SharePoint 2010

SharePoint supports the ability to create Excel-like field validation formulas to validate field data in a list, which greatly reduces the amount of custom code that a developer must create and deploy. (Length: 1:44)

Compare Validation for the Title field of the list

Hi, I do have a field known as 'Title' in the list.My requirement is there should be not be any duplicate values i.e first time if i enter say 'test' in Title field it should save where as second time when i enter same text as 'test' it should show message as 'item already exists with the Title that you have entered'.Ofcourse i should do the compare validation over here but just let me know how to do this Thanks & Regards, Sudheer

List data validation failed error checking in dockument and uploading to library.

If I upload a document to the "vanilla" Document Library at the root site (I have not created sub sites yet, we are in the testing phase), the document does get uploaded but the following error appears: Error List data validation failed.   Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 0928c39a-f2d7-4ce6-8057-62cc01c6a951 Date and Time: 6/16/2010 5:27:58 PM Go back to site -------------------------------------------------------------------------- The doc has uploaded but is automatically checked out to me I am logged on as the ADMINISTRATOR Account Now if I try and discard the check out, it will fail as there is no original checked in version. If I try and click Check in, then the same error appears Help

Validation for dd mm yyyy dropdown list

Hi i have a form which asks for date of birth.please find below the code. <asp:DropDownList ID="ddlDay" runat="server"> </asp:DropDownList> &nbsp;<asp:DropDownList ID="ddlMonth" runat="server"> </asp:DropDownList> &nbsp;<asp:DropDownList ID="ddlYear" runat="server"> </asp:DropDownList> asp:CustomValidator ID="valDate" Text="*" runat="server"      ControlToValidate="ddlDay"  ValidationGroup="Group1" OnServerValidate="valDate_ServerValidate" ClientValidationFunction="valDate_ClientValidate"  ErrorMessage="Please enter a valid date of birth" Display="Dynamic" ForeColor=""  CssClass="validatorText" /> The dropdownlist is populated in code behind. The client and server validation code is,        function valDate_ClientValidate(source, args) {            var dd_id = document.getElementById("<%=ddlDay.ClientID %>");            var mm_id = document.getElementById("<%=ddlMonth.ClientID %>");   &nb

Validation is not working in Custom List Form using JavaScript ddwrt:GenFireServerEvent()

Hii am creating custom New form for a list using sharepoint designer. i have added the below button for sumbit<input name="Submit1" type="submit" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />                <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;                                    </xsl:text><input name="Submit2" type="submit" value="Cancel" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />the problem is the validation is not working properly. it submits the page without entering values for the required fields.particularly the validation is not working for DateFields.let me know what is the problem here. is it a Bug?muthu

how to avoid drop down list validation for databound value


i have multiple drop down lists and using the DataBount event to insert an initial value to populate the drop down list, which does exactly what i want it to do. however, now i have put a required validation control on it and the validation never gets triggered because of my value i insert using this code below. anyway i can get my validation control to avoid the databout value?

        protected void ddlTime_DataBound(object sender, EventArgs e)
            if (ddlTime != null)
                ddlTime.Items.Insert(0, "Available Times");


Data validation in "Custom list"?


Is it possible to do data validation in "Custom list" just like Excel. For eg: I am trying to build where the user selects one option and based on that appropriate option shows up.

Eg: I have two columns - Column1 : Region, Column2: Country

A person selects : Region as Asia this should give him Country option all asian countries.

List Validation Boolean AND OR operators


I need to make a validation that requires two separate tests and both must pass, therefore an AND operator is needed to concantenate the two results.  However, from what I can see the List Validation syntax does not support this.  Any ideas?

Validation script in list schema



Anyone knows what the script tag in the validation element is good for? Do we put javascript here?

<Field ID="" Name="FieldName">
        <Validation Message="Message" Script="What's in here???"></Validation>

Client side validation while "OK" button clicked in list in sharepoint 2007


Hi All,

while saving data to a list in sharepoint all the validation are server side ,can i do it client side in sharepoint 2007

Thanks and Regards Er.Pradipta Nayak

SharePoint 2010 - Column Validation (List Level) User Message Missing


I first saw this issue being discussed in January 2010 here, but there has not been any response in some time. 

What basically happens is when you set column validation for the list level (not per column) the message that alerts the user that the column does not meet the validation requirements is completely missing.   Both the default message or a custom message do not show up. 

Does anyone know if there is a hotfix for this issue yet?  I would expect more than a year later there would be one, but if so I can't seem to find it.  I would really like to correct this issue as column validation is a nice enhancement over SharePoint 2007.  Thanks in advance for any help.

Unexpected "Microsoft.SharePoint.SPListDataValidationException: List data validation failed."


Steps to replicate (I suspect it can be replicated with any list, not just a survey):

1. Create a survey
2. Go to Survey Settings / Validation Settings, enter a formula and a user message.
3. Respond to a survey. 
3.1. If a formula validation succeeds, a new survey response is created.
3.2. If a formula validation fails, I expect to see a user message created in step #2 above. Instead, I see an exception:

 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.SharePoint.SPListDataValidationException: List data validation failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Ready made List Types provided by SharePoint

SharePoint provides some out of the box List Types. Some of the most used ready made list types that SharePoint provides currently are listed below:

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.

Dropdown list in ASP.NET - How to get value selected

am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).
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