Thursday, 22 May 2014

Give custom validation message in HTML5

Custom Message in HTML5

Generally if you are just giving required in input it will give its own validation message in html5. But if you want to give your custom message then do this.

<input id="UserID" type="text" required="required" oninvalid="this.setCustomValidity('Witinnovation')">

Thursday, 17 April 2014

Get added and deleted items from array

This one is only for int array Here i am going to show how to get value of add and deleted items from defined array.


        var oldbrd = $scope.selectedDiagnosis.sort();
        var newbrd = $scope.RefferalView.Diagnosis.sort();

        var additem = [];
        var deleteitem = [];
        //var index;

        angular.forEach(oldbrd, function (value) {
            if (newbrd.indexOf(value) == -1) {
                deleteitem.push(value);
            }
        });

        angular.forEach(newbrd, function (value) {
            if (oldbrd.indexOf(value) == -1) {
                additem.push(value);
            }
        });

        $scope.AddedDiagnosisCode = additem;
        $scope.DeletedDiagnosisCode = deleteitem;
        alert('added =>: ' + additem + "_________" + 'deleted =>: ' + deleteitem);

Tuesday, 19 November 2013

Custom Column Filter only with a single textbox on each column without any operators and buttons.







Here i find custom search functionality for KendoUI grid. Hope you really find helpfull.

HTML
<link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.rtl.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.dataviz.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.dataviz.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2012.3.1114/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://cdn.kendostatic.com/2012.3.1114/js/kendo.all.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="grid"></div>
</body>
</html>
 

JavaScript
  dataSource:[ {
      foo: "Foo 1",
      bar: "Bar 1"
    } , {
      foo: "Foo 2",
      bar: "Bar 2"
    }
  ]
});

var grid = $("#grid").data("kendoGrid");

$("<tr><th class='k-header' data-field='foo'><input /></th><th data-field='bar' class='k-header' ><input /></th></tr>").appendTo($("#grid thead")).find("input").keyup(function() {
 
  grid.dataSource.filter({
    operator: "contains",
    value: $(this).val(),
    field: $(this).parent("th").data("field")
  });
 
});


http://www.kendoui.com/forums/kendo-ui-complete-for-asp-net-mvc/grid/custom-column-filter-only-with-a-single-textbox-on-each-column-without-any-operators-and-buttons.aspx


Another link is

http://jsbin.com/ihanun/1/edit

Wednesday, 13 November 2013

Wednesday, 30 October 2013

Make CSS3 Creatures

Something really amazing with css3 is one of here. You can see below.




So here you go for Html page code

 
Style for it
 




For reference link
http://bennettfeely.com/csscreatures/

Tuesday, 29 October 2013

Which command using Query Analyzer will give you the version of SQL server and operating system?

This one is very important question for interview.

Here you go,

SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition').

Saturday, 19 October 2013

MVC demo

This example for add and search record using entity framework in MVC3 using JSON.

Entity frame work database design is given below:


http://www.asp.net/mvc/tutorials/older-versions/models-%28data%29/creating-model-classes-with-the-entity-framework-cs

HomeController Page
namespace MvcAppVehicleSystem.Controllers

{
    public class HomeController : Controller
    {
        VehicleSysHireEntities2 _db;
        public HomeController()
        {
            _db = new VehicleSysHireEntities2();
        }

        public ActionResult Index()
        {
            var query = _db.VehicleRentTypes.ToList();

            var query2 = _db.VehicleCategories.ToList();

            var model = new Models.SelectViewModel
            {
                CategoryList = query2,
                RentTypeList = query
            };
            return View(model);
        }

        [HttpPost]
        public ActionResult Index(VehicleMasterModel role)
        {
            VehicleMaster currentVehicle = new VehicleMaster();
            currentVehicle.Brand = role.Brand;
            currentVehicle.Category = role.Category;
            currentVehicle.Model = role.Model;
            currentVehicle.Color = role.Color;
            currentVehicle.NoOfYear = role.NoOfYear;
            currentVehicle.RentType = role.RentType;
            _db.AddToVehicleMasters(currentVehicle);
            _db.SaveChanges();

            if (currentVehicle.ID > 0)
            {
                VehicleFacility currentfacility = new VehicleFacility();
                currentfacility.VehicleMasterID = currentVehicle.ID;
                currentfacility.HasABS = role.HasABS;
                currentfacility.HasAirCon = role.HasAirCon;
                currentfacility.HasCTX = role.HasCTX;
                _db.AddToVehicleFacilities(currentfacility);
                _db.SaveChanges();
            }
            return Json(true);
        }

        public ActionResult About()
        {
            var query = _db.VehicleRentTypes.ToList();
            var query2 = _db.VehicleCategories.ToList();
            var model = new Models.SelectViewModel
            {
                CategoryList = query2,
                RentTypeList = query
            };
            return View(model);
        }

        [HttpPost]
        public ActionResult About(VehicleMaster role)
        {
            List objList = (from m in _db.VehicleMasters select m).ToList();
            return Json(objList);
        }

        [HttpPost]
        public ActionResult AboutResult(VehicleMasterModel role)
        {
            var objList = (from m in _db.VehicleMasters
                           where m.RentType == role.RentType
                           select new VehicleMasterModel()
                           {
                               Brand = m.Brand,
                               Model = m.Model
                           }).ToList();
            return Json(objList, JsonRequestBehavior.AllowGet);
        }
    }
}

Model-> SelectViewModel
 public class SelectViewModel

    {

        public List CategoryList { get; set; }

        public List RentTypeList { get; set; }

        public VehicleFacility currentvehiclefacility { get; set; }

        public VehicleMaster currentvehiclemaster { get; set; }

    }

Model-> VehicleCategoryModel
public class VehicleCategoryModel

    {

        public int ID { get; set; }

        public string Category { get; set; }

        public List VehicleCategoryList { get; set; }

    }

Model-> VehicleFacilityModel
  public class VehicleFacilityModel

    {

        public List VehicleMasterList { get; set; }

        public int ID { get; set; }

        public bool HasAirCon { get; set; }

        public bool HasABS { get; set; }

        public bool HasCTX { get; set; }

        public int VehicleMasterID { get; set; }

    }
 
Model-> VehicleMasterModel
 public class VehicleMasterModel

    {

        public int ID { get; set; }

        public int Category { get; set; }

        public string Brand { get; set; }

        public string Model { get; set; }

        public string Color { get; set; }

        public int NoOfYear { get; set; }

        public int RentType { get; set; }

        public bool HasAirCon { get; set; }

        public bool HasABS { get; set; }

        public bool HasCTX { get; set; }

        public int VehicleMasterID { get; set; }

    }

Model-> VehicleRentTypeModel
 public class VehicleRentTypeModel

    {

        public int ID { get; set; }

        public string RentType { get; set; }

        public List  VehicleRetTypeList { get; set; }

    }

Home->Index
@{
    ViewBag.Title = "Home Page";
}

@ViewBag.Message

@model MvcAppVehicleSystem.Models.SelectViewModel
Type @Html.DropDownList("ddlType", new SelectList(Model.RentTypeList, "ID", "RentType"), "Select Type", new { required = "required" }) Category @Html.DropDownList("ddlCategory", new SelectList(Model.CategoryList, "ID", "Category"), "Select Category", new { required = "required" })
Model @Html.DropDownList("ddlModel", new[] { new SelectListItem() {Text = "Audi",Value = "Audi"}, new SelectListItem() {Text = "Maruti",Value = "Maruti" }, new SelectListItem() {Text = "Suzuki",Value = "Suzuki" } }, "Choose model", new { required = "required" }) No of year @Html.DropDownList("ddlNoofYear", new[] { new SelectListItem() {Text = "2010",Value = "2010"}, new SelectListItem() {Text = "2011",Value = "2 011" }, new SelectListItem() {Text = "2012",Value = "2012" }, new SelectListItem() {Text = "2013",Value = "2013" } }, "Choose year", new { required = "required" })
Brand Has AirCon Has ABS Has CTX
Colour

Home->About
@{
    ViewBag.Title = "Search";
}
@model MvcAppVehicleSystem.Models.SelectViewModel

Search

Type @Html.DropDownList("ddlType", new SelectList(Model.RentTypeList, "ID", "RentType"), "Select Type")
No of year @Html.DropDownList("ddlNoofYear", new[] { new SelectListItem() {Text = "2010",Value = "2010"}, new SelectListItem() {Text = "2011",Value = "2011" }, new SelectListItem() {Text = "2012",Value = "2012" }, new SelectListItem() {Text = "2013",Value = "2013" } }, "Choose year")