Translate

Wednesday, 29 April 2015

How to check Checkbox checked or Not using jquery(terms and conditions checkbox)




In View


<script>
    $(function () {
        $('#btnconfirm').click(function () {
            if ($("#chk").attr('checked') !== undefined ){
                return true;
            }
            else {

                alert("Please Select Checkbox ");
                return false;
            }
        });

    });
</script>
<div style="float: left">
                    <input type="checkbox" name="chk" id="chk"  />
                    I read and accept the terms and Conditions of registration
                </div>
  <input type="submit" value="Confirm"  id="btnconfirm" />

Tuesday, 28 April 2015

Image Sliding With bxSlider Plugins in MVC


Image Sliding In mvc using bxslider Plugins

In Controller


public ActionResult ImageSliding()
        {

            var uploadedFiles = new List<Sample>();
            var files = Directory.GetFiles(Server.MapPath("~/Img"));
            Sample uploadedFile = null;
            if (files.Count() > 0)
            {

                foreach (var file in files)
                {
                    var fileInfo = new FileInfo(file);
                    uploadedFile = new Sample() { Name = Path.GetFileName(file) };

                    uploadedFile.Path = ("/Img/") + Path.GetFileName(file);
                    uploadedFile.Size = Convert.ToString((fileInfo.Length) / 1000);
                    uploadedFiles.Add(uploadedFile);
                }
                uploadedFile.images = uploadedFiles;
            }
            return View(uploadedFile);

        }

In view





@model JQGridExample.Models.Sample
@{
    ViewBag.Title = "ImageSliding";
}

<h2>ImageSliding</h2>


<!doctype html>
<html>
<head>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

  <script>
      $(function () {
          $(document).ready(function () {
              $('.bxslider').bxSlider({
             
                                auto:true,
                        autoControls: true, mode: 'fade'
                              });
          });
      });
  </script>
</head>
<body>


    <ul class="bxslider" >
     @foreach(var item in Model.images)
     {
         <li><img src="@item.Path" /></li>
     }
</ul>
  

</body>
</html>
<link href="~/Content/css/jquery.bxslider.css" rel="stylesheet" />
<script src="~/Content/js/jquery.bxslider.min.js"></script>



OutPut



Data table In MVC

Data table In MVC is show below.


In Model

public class Sample
    {
        public string UserName { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Location { get; set; }
        public string Name { get; set; }
        public string Path { get; set; }
        public string Size { get; set; }
        public List<Sample> images { get; set; }
        public int Id{get;set;}
        public List<Sample> Listgrid { get; set; }
        KavithaEntities1 context = new KavithaEntities1();

        public List<Sample> GetList()
        {
            List<Sample> ListDetails = new List<Sample>();
            Sample Smpl = null;
            var list = context.sp_GetList_Jqgrid().ToList();
            for (int i = 0; i < list.Count(); i++)
            {
                Smpl = new Sample();
                Smpl.UserName = list[i].UserName;
                Smpl.FirstName = list[i].FirstName;
                Smpl.LastName = list[i].LastName;
                Smpl.Location = list[i].Location;
                Smpl.Id = Convert.ToInt32(list[i].Id);
                ListDetails.Add(Smpl);
            }
            return ListDetails;
        }


    }


In Controller:

public ActionResult DataTable()
      {
            Sample sample = new Sample();
            List<Sample> lst = new List<Sample>();
            lst = sample.GetList();
            return View(lst);
        }


In View

@model IEnumerable<JQGridExample.Models.Sample>
@{ 
      Layout = "~/Views/Shared/_Layout.cshtml"
 } 
@* <link href="@Url.Content("~/Content/dataTables/demo_table.css")" rel="stylesheet" type="text/css" />*@
<link href="~/Content/jquery.dataTables.css" rel="stylesheet" />
<script src="~/Scripts/DataTable/jquery-1.4.4.min.js"></script>
<script src="~/Scripts/DataTable/jquery.dataTables.min.js"></script>
<script src="~/Scripts/DataTable/jquery.dataTables.js"></script>
<script src="~/Scripts/DataTable/index.js"></script>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>MyView</title>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#tblObjects').dataTable({
            });

        });
</script>
</head>
<body>
    <div>
         <table id="tblObjects" class="datatable">
        <thead>
            <tr>
                <th>User Name</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Location</th>
               
            </tr>
        </thead>
       
           @if (Model != null && Model.Count() > 0)
            {
                <tbody>
                    @foreach (var item in Model)
                    {
                        <tr>

                            <td>@Html.DisplayFor(modelItem =>item.UserName)</td>
                            <td>@Html.DisplayFor(modelItem => item.FirstName)</td>
                            <td>@Html.DisplayFor(modelItem => item.LastName)</td>
                             <td>@Html.DisplayFor(modelItem => item.Location)</td>
                        </tr>
                    }
                   

                </tbody>
           }
       
   </table>
    
    </div>
</body>
</html>