Friday, 1 April 2016

CountDown To Show Under Construction Page Using jQuery In Asp.Net MVC

4/01/2016 - By Pranav Singh 0

This article will show you how you can create under construction page using jquery in asp.net mvc. In this you just need to pass the day, month, year, hour, minute and second to display the under construction timer.

First you need to download the plugin library.
So for this article first we will create a new asp.net mvc application add a model class. In this model class file add the below code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcApplication1.Models
{
    public class UnderConstructionModel
    {
        public int day { get; set; }
        public int month { get; set; }
        public int year { get; set; }
        public int hour { get; set; }
        public int min { get; set; }
        public int sec { get; set; }
    }
}

In above model class file I have add the day, month, year, hour, minute and second. Now add the controller class file and add the below code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            UnderConstructionModel underConstructionModel = new UnderConstructionModel();
            underConstructionModel.day = 1;
            underConstructionModel.month = 5;
            underConstructionModel.year = 2016;
            underConstructionModel.hour = 0;
            underConstructionModel.min = 0;
            underConstructionModel.sec = 0;
            return View(underConstructionModel);
        }

    }
}

In above code I have passed the day, month, year, hour, minute and second. Now create view and add the below code jquery and css reference.
<link href="../../Css/main.css" rel="stylesheet" type="text/css" />
    <script src="../../Js/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Js/jquery.lwtCountdown-1.0.js" type="text/javascript"></script>
    <script src="../../Js/misc.js" type="text/javascript"></script>

Now check the complete code.
@model MvcApplication1.Models.UnderConstructionModel
@{
    ViewBag.Title = "CountDown To Show Under construction Page Using jQuery In Asp.Net MVC";
    <link href="../../Css/main.css" rel="stylesheet" type="text/css" />
    <script src="../../Js/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Js/jquery.lwtCountdown-1.0.js" type="text/javascript"></script>
    <script src="../../Js/misc.js" type="text/javascript"></script>
}
<div id="container">
    <h1>
        UNDER CONSTRUCTION</h1>
        <br />
    <div id="countdown_dashboard">
        <div class="dash weeks_dash">
            <span class="dash_title">weeks</span>
            <div class="digit">
                0</div>
            <div class="digit">
                0</div>
        </div>
        <div class="dash days_dash">
            <span class="dash_title">days</span>
            <div class="digit">
                0</div>
            <div class="digit">
                0</div>
        </div>
        <div class="dash hours_dash">
            <span class="dash_title">hours</span>
            <div class="digit">
                0</div>
            <div class="digit">
                0</div>
        </div>
        <div class="dash minutes_dash">
            <span class="dash_title">minutes</span>
            <div class="digit">
                0</div>
            <div class="digit">
                0</div>
        </div>
        <div class="dash seconds_dash">
            <span class="dash_title">seconds</span>
            <div class="digit">
                0</div>
            <div class="digit">
                0</div>
        </div>
    </div>
    <script language="javascript" type="text/javascript">
        jQuery(document).ready(function () {
            $('#countdown_dashboard').countDown({
                targetDate: {
                    'day': @Model.day,
                    'month': @Model.month,
                    'year': @Model.year,
                    'hour': @Model.hour,
                    'min': @Model.min,
                    'sec': @Model.sec
                }
            });
        });
              </script>
</div>

In above code I have added the model class value into the counter function. After execution we whatever value we will pass value it will get displayed. Now we have done. Run the application to 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