Click here to Skip to main content
11,721,053 members (83,212 online)
Click here to Skip to main content

A Simple ASP.NET MVC Grid with Multilingual Support+Drop Down Menu

, 2 Nov 2013 CPOL 6.4K 4
Rate this:
Please Sign up or sign in to vote.
Using grid and search grid using Ajax or without Ajax, and using Resource Files to enable multi language support

Introduction

In this source code, I've tried to combine a very simple ASP.NET MVC application without using any database, + showing results in Grid, Search via customer name, and using resource files to enable multi-language support.

Using the Code

This solution has 2 projects, Common (class library) and Application. Common project contains only the resource files required to multi-language support of the application.

WebApplication uses the default Visual Studio 2012 template. I have added a simple Customer model to use in project (edit, search and create) views for this model had been added to.

To search customer grid, JQuery UI auto complete facility has been used in search textbox. Also it's possible for you to run the grid partially or with a submit button:

//creating Model

public class CustomerModel
    {
        private static List<CustomerModel> _list = null;

        private static int count = 0;
        public CustomerModel()
        {
            count++;
            Id = count;
        }
        [Required]
        public int Id { get; set; }

        [StringLength(20, ErrorMessage = "مقدار وارد شده بیش از حد مجاز است")]
        [Display(Name = "Name", ResourceType = typeof(Resource))]
        [Required(ErrorMessageResourceName = "Err_IsRequired", ErrorMessageResourceType = typeof(Resource))]
        public string Name { get; set; }

        [StringLength(30, ErrorMessage = "مقدار وارد شده بیش از حد مجاز است")]
        [Required(ErrorMessageResourceName = "Err_IsRequired", 
        ErrorMessageResourceType = typeof(Resource))]
        [Display(Name = "LastName", ResourceType = typeof(Resource))]
        public string LastName { get; set; }

        [Required(ErrorMessageResourceName = "Err_IsRequired", 
        ErrorMessageResourceType = typeof(Resource))]
        [Display(Name = "Gender", ResourceType = typeof(Resource))]
        public int Gender { get; set; }

        [Required(ErrorMessageResourceName = "Err_IsRequired", 
        ErrorMessageResourceType = typeof(Resource))]
        [Display(Name = "EducationId", ResourceType = typeof(Resource))]
        public int EducationId { get; set; }
//this is the index view of customer using grid and search method

@using (Html.BeginForm("Index", "Customer", 
FormMethod.Post, new { id = "searchForm" }))
{
    @Html.EditorFor(c => c.SearchTerm)
    <button class="action" style="float: none" 
    onclick="search();return false;">
    <span class="activeIcon icon198"></span>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Member 626383
Software Developer (Senior) DPI
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 2 Nov 2013
Article Copyright 2013 by Member 626383
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid