Posts

jQuery DatePicker in MVC

Code:       <script>         $(document).ready(function () {             $("#StartDate").datepicker({                 dateFormat: "dd-mm-yy",                 changeMonth: false,                 changeYear: false,                 yearRange: "-0:+0",                 numberOfMonths :1,//This Property is use to set Diplay Number Of month                 buttonText: "submit",                                  onSelect: function (selectDate) {                     $("#EndDate").datepicker("option", "minDate",selectDate)//Set the...

How To insert CheckBox Data in Database -- MVC

View Code : <div class="form-horizontal">     <h4>CheckBoxModel</h4>     <hr />     @Html.ValidationSummary(true, "", new { @class = "text-danger" })          <div class="form-group">         @Html.LabelFor(model => model.song, htmlAttributes: new { @class = "control-label col-md-2" })          <div class="form-group">         @Html.LabelFor(model => model.hoky, htmlAttributes: new { @class = "control-label col-md-2" })         <div class="col-md-10">             @Html.EditorFor(model => model.hoky, new { htmlAttributes = new { @class = "form-control" } })             @Html.ValidationMessageFor(model => model.hoky, "", new { @class = "text-danger" })         </div>     ...

How To insert Radio Button Data in DataBase -- MVC

View code :   <div class="form-horizontal">         <h4>MyRadioButtonDemo</h4>         <hr />         @Html.ValidationSummary(true, "", new { @class = "text-danger" })         <div class="form-group ">             @Html.LabelFor(model => model.Gender, htmlAttributes: new { @class = "control-label col-md-2" })             <div class="col-md-10 " >                 <label class="radio-inline">                     @Html.RadioButtonFor(model=>model.Gender,"Male",new { @name="gender"})                     male                 </label>                 <...

insert Data in DataBase using Ajex BeginForm in MVC

View Code : @model Ajex_MVC.Models.MyCroud  @{     ViewBag.Title = "Create"; } <h2>Create</h2> <div id="LodingImg" style="display:none">     <img src="~/Content/img/Loading.jfif" height="100" width="100" /> </div> <div id="DivForUpdate">        </div> @using (Ajax.BeginForm("Create", "Home",                           new AjaxOptions() {                               HttpMethod = "POST",                               InsertionMode = InsertionMode.Replace,                               UpdateTargetId = "DivForUpdate",               ...

jQuery Check Box change Event

Code  jQuery : <script>         $(document).ready(function () {             $("#No").change(function () {                 if ($(this).is(":checked")) {                     var returnVal = confirm("are you sure ??? ");                     $(this).attr("checked", returnVal);                     alert(" no check box is checked");                 }             });         });           </script>

Cookies in MVC

Creating Cookie in Clint side Browser .  HttpCookie cookie = new HttpCookie("Cookie Name");//cookie is object of HttpCookie                 cookie.Value = md.Userid + md.password;//Set value of cookie                 HttpContext.Response.Cookies.Add(cookie);//Add cookie in Browser                 cookie.Expires.AddDays(1);    //Set Time of Cookie Expiring Time Expiring Cookie . [Route("out")]         public ActionResult logout()         {             HttpCookie cookie = new HttpCookie("LoginCookie");             if (Request.Cookies["LoginCookie"] != null)             {                 HttpCookie myCookie = new HttpCookie("LoginCookie");       ...

All The Regular Expression For Validation In MVC

Model Code :  [RegularExpression(@"^[a-zA-Z\s]+", ErrorMessage ="pleace enter Valied name ")]         [Required(ErrorMessage ="First Name Required")]         public string FirstName { get; set; }  [RegularExpression(@"^[a-zA-Z\s]+", ErrorMessage ="pleace enter Valied name ")]         [Required(ErrorMessage ="Last name Required")]         public string LastName { get; set; }          [Required(ErrorMessage ="Age Required ")]         [Range(18,95,ErrorMessage ="Pleace Enter valied Age")]         public string Age { get; set; }         [Required(ErrorMessage ="Password Required")]         [RegularExpression(@"((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})", ErrorMessage ="pleace enter special cherector, number ,minimum7 chearector")]     ...