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.
Some of my previous articles are as follows: Bootstrap
Style Dynamic jQuery Dropdowns Menu Using Asp.Net MVC In C#.Net, Blink
Title or Multiple Browser Title Using jQuery in Asp.Net, MVC, Social
Share Buttons of Facebook, Twitter, Google Plus and Pinterest Using jQuery in
Asp.Net MVC, Bootstrap
3 and jQuery Form Validation Plugin in Asp.Net MVC, MultiSelect
DropdownList Using jQuery in Asp.Net MVC and C#.Net, jQuery
Digital Clock For Asp.Net, MVC and HTML Applications.
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>
|
0 comments:
Please let me know your view