Thursday, 24 July 2014

jQuery UI Calender Open With LightBox Effect in Asp.Net MVC

7/24/2014 - By Pranav Singh 0

This article will show you how you can open a jQuery ui calendar in asp.net mvc application with lightbox effect or in modular popup effect using jQuery. In this article I will show you how you can add a jQuery UI calendar and retrace the selected date at controller end and display in view.

So for this article first we will create a new asp.net mvc application.  Add a controller in it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; 
namespace DateTimepickerinModelWindow.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(string Datepicker)
        {
            ViewBag.DateValue = Datepicker;
            return View();
        }
    }
}

Now create view and add the below code.

@{
    ViewBag.Title = "jQuery UI Calender Open With LightBox Effect in Asp.Net MVC";
}
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<style type="text/css">
    .black_overlay
    {
        display: none;
        position: absolute;
        top: 0%;
        left: 0%;
        width: 100%;
        height: 100%;
        background-color: black;
        z-index: 1001;
        -moz-opacity: 0.8;
        opacity: .80;
        filter: alpha(opacity=80);
    }
   
    .white_content
    {
        display: none;
        position: absolute;
        top: 10%;
        left: 10%;
        width: 300px;
        height: 250px;
        padding: 4px;
        border: 3px solid orange;
        background-color: white;
        z-index: 1002;
        overflow: auto;
    }
</style>
<script language="javascript">
    function UserLoginOpen() {
        document.getElementById('light').style.display = 'block';
        document.getElementById('fade').style.display = 'block';
    }
    function UserLoginClose() {
        document.getElementById('light').style.display = 'none';
        document.getElementById('fade').style.display = 'none';
        return false;
    }
</script>
<script>
    $(function () {
        $("#txtdatepicker").datepicker();
    });
</script>
@using (Html.BeginForm("Index", "Home"))
{
   
    <div style="text-align: center; padding-top: 20%;">
        <a href="#" onclick="javascript:UserLoginOpen();">Click To Open Calender In LightBox</a>
    </div>
    <div id="fade" class="black_overlay">
    </div>
    <div id="light" class="white_content">
        @Html.TextBox("Datepicker", "", new { @id = "txtdatepicker", @style = "width:150px;" })
        <br />
        <input type="submit" value="Submit" />
        <input id="btnclose" type="button" value="Close" onclick="javascript:return UserLoginClose();" />
        <br />
    </div>  
    <div  style="text-align: center;">
        Your selected date :@ViewBag.DateValue
    </div>
}

In above code I have added style sheet for lightbox effect, and used jQuery calendar to display. In this selected date will store in viewbag and display it.

Now run the application and check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top