Today you can see numerous blogs and websites around you and there would be many blogs with unique features that you would like to have in your WordPress blog or site. However, it is not possible for everyone to know what they have to do to get unique features in their blogs or where to look for those features. This article will try to share some hacks and tricks that will be very useful for the WordPress development company and developers.
Set Custom Page as a Home Page in WordPress
This is the main feature that every developer wants to know where they can create their own design and set it as the home page of their blog. Create a new template or duplicate your PHP file as a template and log in to your WordPress admin panel. Publish your page and go to the option to select the custom homepage and point it to your newly created page. This is the simplest trick to have your custom designed page as your home page.
Create Page To Show Random Posts
This is the feature that is liked by every reader and developer. Web design company New Zealand have confirmed that all of their clients want this feature where their readers are shown random posts every time they refresh the page.
This is very simple method, first you have to create a custom page as mentioned above and then you have to add a simple WordPress Loop script that will show one post every time the page is refreshed. However, you have the option to increase the number of the posts.
Display External RSS feed in WordPress
Many times we see that bloggers display feeds of their other blogs on their site. This is the simplest trick to increase your traffic. Adding below mentioned codes anywhere in your theme will do the magic.
<?php echo ‘Posted ‘.$item->get_date(‘j F Y | g:i a’); ?>
Display Relative Dates
For the bloggers having good knowledge about the plugins of WordPress this is very simple job. All you have to do is download plugin called WP-Relative Date and activate the plugin. WordPress plugin development NZ are using this trick to please their clients.
News in a WordPress Site
This is the trick that is adapted by the top bloggers and sites to ensure that the useful section is displayed in the sidebar that is actually posted by the audience. This simple job can be accomplished by downloading plugin called TDO Mini Forms and activate it. There is no need of having any extra knowledge for this, just follow the instructions displayed and your site will be ready.
Hope the above mentioned tricks are useful for you.
Like many other popular things, web design using WordPress also experiences myths getting associated with it for no strong reason. It is a challenging task for the developer to address these myths on a regular basis and filter out the small fraction of truth from the enormous amount of false conceptions. The main idea is to make sure that the performance and safety of the website is maintained.
Popular WordPress Development Myths Revealed
Numerous online stores uses WordPress development for their websites. Due to the prevalence of some myths there are still many individuals who hesitate integrating WordPress. Let us get into the depth of these myths and analyze how true they are:-
Website Speed is Slowed if WordPress Revisions Are Made
The various WordPress revisions never add to the slow performance of any website. MySQL database used usually manages all such revisions as in WordPress there occurs no provisions for revisions made at its front end. It is true that revisions do occupy some space inside the database but for standard users it causes no negative impact.
Usage of Plugins Slows Down The Website
There is a myth in the minds of certain people that using plugins given by WordPress slows down the site. WordPress plugin development company India clears the myth because the statement is valid only under certain cases. Only if a plugin is bulky in its weight then it can slow down the website if integrated within it. It can be noted that certain plugins are installed to speed up site performances.
Plugins Inactive Also Slows Down Site
Plugins which are used inside a WordPress website and are not in use can slow down the speed is another popular myth. It is not true. Inactive plugins do not affect speed. However, it is a healthy practice to uninstall plugins which have no usage to avoid weaknesses and security issues for the website. WordPress plugin development India does not update plugins which are inactive and hence can be a potential security threat.
Themes Not Active Slows Speed Down
Similar to the plugin myth, themes which are not in use do not slow down the site. Many times for WordPress customization India individuals use multiple themes. Many of these are not used as at one point of time WordPress can use only a single theme. However keeping unused items away is a good practice.
Trash Accumulation Affects Website Speed
WordPress engines have an inbuilt function to manage large trash amounts, comments, spams due to its interactive platform base. Hence, when trash occurs in WordPress it gets stored in the MySQL. This never affect the website’s loading time or speed.
In this tutorial, we will discuss about creating Google column chart with animation on load using ASP.NET MVC4 & Jquery. A column chart is a vertical bar chart rendered in the browser using SVG or VML, whichever is appropriate for the user’s browser. Like all Google charts, column charts display tooltips when the user hovers over the data. For a horizontal version of this chart, see the bar chart.
Steps :
1 – Create New Project.
Go to File > New > Project > Select asp.net MVC4 web application > Entry Application Name > Click OK > Select Internet Application > Select view engine Razor > OK
2 – Add a Database.
Go to Solution Explorer > Right Click on App_Data folder > Add > New item > Select SQL Server Database Under Data > Enter Database name > Add.
3 – Create table for get data for chart.
Open Database > Right Click on Table > Add New Table > Add Columns > Save > Enter table name > Ok.
In this example, I have used one tables as below
4- Add Entity Data Model.
Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > New item > Select ADO.net Entity Data Model under data > Enter model name > Add. A popup window will come (Entity Data Model Wizard) > Select Generate from database > Next > Chose your data connection > select your database > next > Select tables > enter Model Namespace > Finish.
5 – Add a new Controller.
Go to Solution Explorer > Right Click on Controllers folder form Solution Explorer > Add > Controller > Enter Controller name > Select Templete “empty MVC Controller”> Add.
6 -Add new action into your controller for Get Method.
Here I have added “Column” Action into “GoogleChart” Controller. Please write this following code
public ActionResult Column()
{
return View();
}
7 – Add view for the Action & design.
Right Click on Action Method (here right click on form action) > Add View… > Enter View Name > Select View Engine (Razor) > Check “Create a strong-typed view” > Select your model class > Add.
8 – Add jquery code for create google animated Chart.
<script>
$(document).ready(function () {
//Load Data Here
var chartData = null;
$.ajax({
url: '/GoogleChart/GetSalesData',
type: 'GET',
dataType: 'json',
data: '',
success: function (d) {
chartData = d;
},
error: function () {
alert('Error!');
}
}).done(function () {
drawChart(chartData);
});
});
function drawChart(d) {
var chartData = d;
var data = null;
data = google.visualization.arrayToDataTable(chartData);
var view = new google.visualization.DataView(data);
view.setColumns([0, {
type: 'number',
label: data.getColumnLabel(0),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(1),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(2),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(3),
calc: function () { return 0; }
}]);
var chart = new google.visualization.ColumnChart(document.getElementById('visualization'));
var options = {
title: 'Sales Report',
legend: 'bottom',
hAxis: {
title: 'Year',
format: '#'
},
vAxis: {
minValue: 0,
maxValue: 1000000,
title: 'Sales Amount'
},
chartArea: {
left:100, top: 50, width:'70%', height: '50%'
},
animation: {
duration: 1000
}
};
var runFirstTime = google.visualization.events.addListener(chart, 'ready', function () {
google.visualization.events.removeListener(runFirstTime);
chart.draw(data, options);
});
chart.draw(view, options);
}
google.load('visualization', '1', { packages: ['corechart'] });
</script>
9 – Add another new action into your controller for fetch json data for Chart.
Here I have added “GetSalesData” Action into “GoogleChart” Controller. Please write this following code
public JsonResult GetSalesData()
{
List<SalesData> sd = new List<SalesData>();
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
sd = dc.SalesDatas.OrderBy(a => a.Year).ToList();
}
var chartData = new object[sd.Count + 1];
chartData[0] = new object[]{
"Year",
"Electronics",
"Book And Media",
"Home And Kitchen"
};
int j = 0;
foreach (var i in sd)
{
j++;
chartData[j] = new object[] {i.Year, i.Electronics, i.BookAndMedia, i.HomeAndKitchen };
}
return new JsonResult {Data = chartData, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
Complete View
@{
ViewBag.Title = "Column";
}
<h2>Column Chart With Animation</h2>
<br />
<div id="visualization" style="width:600px; height:300px">
</div>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@section Scripts{
<script>
$(document).ready(function () {
//Load Data Here
var chartData = null;
$.ajax({
url: '/GoogleChart/GetSalesData',
type: 'GET',
dataType: 'json',
data: '',
success: function (d) {
chartData = d;
},
error: function () {
alert('Error!');
}
}).done(function () {
drawChart(chartData);
});
});
function drawChart(d) {
var chartData = d;
var data = null;
data = google.visualization.arrayToDataTable(chartData);
var view = new google.visualization.DataView(data);
view.setColumns([0, {
type: 'number',
label: data.getColumnLabel(0),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(1),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(2),
calc: function () { return 0; }
}, {
type: 'number',
label: data.getColumnLabel(3),
calc: function () { return 0; }
}]);
var chart = new google.visualization.ColumnChart(document.getElementById('visualization'));
var options = {
title: 'Sales Report',
legend: 'bottom',
hAxis: {
title: 'Year',
format: '#'
},
vAxis: {
minValue: 0,
maxValue: 1000000,
title: 'Sales Amount'
},
chartArea: {
left:100, top: 50, width:'70%', height: '50%'
},
animation: {
duration: 1000
}
};
var runFirstTime = google.visualization.events.addListener(chart, 'ready', function () {
google.visualization.events.removeListener(runFirstTime);
chart.draw(data, options);
});
chart.draw(view, options);
}
google.load('visualization', '1', { packages: ['corechart'] });
</script>
}
Today’s turotial is about how to search record in MVC with Ajax and jQuery. This code will filter out all matching records group by table column name.
First thing that you should do is create an empty ASP.NET MVC project. Now, add two class to your model. Employee and DemoContext and write the following code:
namespace SearchingDemo.Models
{
public class Employee
{
[Key]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Position { get; set; }
}
}
namespace SearchingDemo.Models
{
public class DemoContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
}
}
Add a Home Controller. Now, Add index Action to controller. and create corresponding view.
public ActionResult Index()
{
return View();
}
Now, write the following code to Index View.
<link href="~/Content/Style.css" rel="stylesheet" />
<script src="~/Content/jquery-2.1.1.min.js"></script>
<script src="~/Content/CustomJs.js"></script>
<h2>Seaching Demo</h2>
<div class="divFind">
<table>
<tr>
<td>
<input type="text" id="txtSearch" />
</td>
<td>
<input type="button" id="btnSearch" value="Seach" />
</td>
</tr>
</table>
</div>
<div id="divList">
</div>
Write the .JS code for click event on seach button to get filtered result. add following .JS code.
Javascript code calling search function, which is written in controller. Add search function to your controller.
public JsonResult Search(string searchKey)
{
DemoContext dbObj = new DemoContext();
var getKey = searchKey.Trim();
var getFirstName = dbObj.Employees.Where(n => n.FirstName.Contains(getKey)).ToList();
var getLastName = dbObj.Employees.Where(n => n.LastName.Contains(getKey)).ToList();
var getPostion = dbObj.Employees.Where(n => n.Position.Contains(getKey)).ToList();
IList<IList<Employee>> getTotal = new List<IList<Employee>>();
getTotal.Add(getFirstName);
getTotal.Add(getLastName);
getTotal.Add(getPostion);
int count = getTotal.Count();
return Json(getTotal);
}
HostForLIFE.eu ASP.NET MVC 6 Hosting HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.
In this tutorial, I will explain how to DROP or DELETE SQL Database. Let me show you how to empty and delete all SQL Database. Now write the following code snippet for Clear Blank SQL Database:
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped Procedure: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO
/* Drop all views */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 ORDER BY [name])
WHILE @name IS NOT NULL
BEGIN
SELECT @SQL = 'DROP VIEW [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped View: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'V' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO
/* Drop all functions */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 ORDER BY [name])
WHILE @name IS NOT NULL
BEGIN
SELECT @SQL = 'DROP FUNCTION [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped Function: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] IN (N'FN', N'IF', N'TF', N'FS', N'FT') AND category = 0 AND [name] > @name ORDER BY [name])
END
GO
/* Drop all Foreign Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)
WHILE @name is not null
BEGIN
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
WHILE @constraint IS NOT NULL
BEGIN
SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint) +']'
EXEC (@SQL)
PRINT 'Dropped FK Constraint: ' + @constraint + ' on ' + @name
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
END
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY TABLE_NAME)
END
GO
/* Drop all Primary Key constraints */
DECLARE @name VARCHAR(128)
DECLARE @constraint VARCHAR(254)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)
WHILE @name IS NOT NULL
BEGIN
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
WHILE @constraint is not null
BEGIN
SELECT @SQL = 'ALTER TABLE [dbo].[' + RTRIM(@name) +'] DROP CONSTRAINT [' + RTRIM(@constraint)+']'
EXEC (@SQL)
PRINT 'Dropped PK Constraint: ' + @constraint + ' on ' + @name
SELECT @constraint = (SELECT TOP 1 CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' AND CONSTRAINT_NAME <> @constraint AND TABLE_NAME = @name ORDER BY CONSTRAINT_NAME)
END
SELECT @name = (SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE constraint_catalog=DB_NAME() AND CONSTRAINT_TYPE = 'PRIMARY KEY' ORDER BY TABLE_NAME)
END
GO
/* Drop all tables */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 ORDER BY [name])
WHILE @name IS NOT NULL
BEGIN
SELECT @SQL = 'DROP TABLE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
PRINT 'Dropped Table: ' + @name
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'U' AND category = 0 AND [name] > @name ORDER BY [name])
END
GO
HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality – beyond other hosting control panels – and ease of use, Plesk Control Panel is available only to HostForLIFE’s customers. Theyoffer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.
Microsoft Azure is now popularly known as Windows Azure, the cloud computing platform that is developed by Microsoft for building, managing and deploying the applications and the services through the network of Microsoft data centers. It offers IaaS and PaaS services and supports various programming languages, frameworks and tools, including the third-party and Microsoft-specific software and systems.
Characteristics
Azure is the Microsoft’s cloud application platform. Recently in 2012, Azure came up with the following features:
• The websites allow the developers to build the sites by using PHP, ASP.NET, Python or Node.js, and can be distributed by using Git, FTP or Mercurial Server.
• The virtual machines allow the developers to travel from the infrastructure without changing the code, and thus can run the Linux machines and the Windows Server. Cloud services also support the automated deployments and multi-tier scenarios. Microsoft’s Platform Service is used in order to create extensive applications and services.
Data Management
The SQL Database, which was previously well-known as the SQL Azure Database, works to scale and extend applications in the cloud by using SQL server technology.
Media Services
Paas can be used for content protection, encoding, and streaming or analytics. The Microsoft Azure Platform offers an API built on the HTTP, REST and XML which allows the developer to connect with the services which is offered by Azure. Moreover, it also integrates with Git, Eclipse and Microsoft Visual Studio. It also provides the managed library class which epitomizes the functions of connecting with the services.
Other Services
Websites : It helps in the hosting of websites. The customers create the sites in ASP.NET, PHP, Python or Node.js and you can also select from various open source applications available in the gallery in order to deploy. This consists of an aspect of Platform as a Service (PaaS) offerings for the Azure.
Virtual Machines : The Azure virtual machines consist of Infrastructure as the service providing from Microsoft to the public cloud. As the preview, these machines supported the Windows Server 2008 and 2012 systems and distributors of Linux. The customers can also create the Virtual Machines, which they have control in order to run the Data Centers.
Cloud Services : The cloud computing services are the containers of the hosted applications. The applications are usually public web applications, like e-commerce solutions or websites. Developers write code, mainly for the cloud services in different programming languages. They can also be used in the private processing engines for some other work, like processing orders or the analyzing data. However, some of the software development kits are commenced by Microsoft for Java, Python and NET. The other languages support through the open source projects.
Implementation : Azure uses the specialized operating system known as Microsoft Azure in order to run “fabric layer”, which is hosted at Microsoft’s data centers, which manages the storage and computing resources of the computers and the provisions of the resources to the application running on the of Azure. Reliability and Scaling are controlled by the Azure Fabric Controller. The Microsoft Azure is described as the “cloud layer” on the Server Systems that use Windows Server 2008 and also the customized version of the Hyper-V, popularly known as the Azure Hypervisor in order to provide virtualization of the services. So, the environment and the services don’t crash if the server crashes within the data center and offers the management of the user’s web application, such as the load balancing and the memory resources.
Privacy : Microsoft Azure has stated, according to the USA Patriot Act, the US government has the access to the data ven though the hosted company is not American and the data resides outside the USA. Azure is a compliant with E.U. data Protection Directive. In order to manage the Security and Privacy related concerns, Microsoft has created the Microsoft Trust Center.
In computer science, data validation is the process of ensuring that a program operates on clean, correct and useful data. It uses routines, often called “validation rules” “validation constraints” or “check routines”, that check for correctness, meaningfulness, and security of data that are input to the system. The rules may be implemented through the automated facilities of a data dictionary, or by the inclusion of explicit application program validation logic.
If you’re developing rich web clients using Asp.net MVC on the back-end, you’ve probably come across this functionality that can be described with these conditions:
client side data (may be a form),
ajax posting of this data (form),
controller action has strong type parameters,
controller action processes data and returns anything but a full view (since it was an Ajax call)
Familiar? Then you’ve come across this problem: »What should be done when validation fails?« Seems fairly straight forward, right? Well not so fast my fellow developer friend…
Old Fashioned
Validation in Asp.net MVC is really simple and very transparent. If you had to think about it all the time when developing Asp.net Web forms applications, you don’t have to do that with MVC anymore. Whenever your controller action takes strong type parameters and you define validation rules on the type itself, you can easily just lay back and watch the magic happen in front of your eyes.
When you don’t use Ajax (how old fashioned of you), your form will be posted back the usual way by means of browser reloading the whole page. Because browser reloads the whole page there will be some flickering since it will clear the window at a certain point to render the new response. So your application will have a master view (in terms of master/detail process), where the user could click some Add new link or button that will redirect them to the new entity view (the details view). This view presents a form where they enter relevant data and a button to submit it to server. Your controller action could look very similar to this:
[HttpPost]
public ActionResult Add(Person instance)
{
if (!this.ModelState.IsValid)
{
// return the same view with validation errors
return View(instance);
}
// save the new person instance and go back to master view
Person result = this.Service.Add(instance);
return RedirectToAction("Index");
}
Contemporary
But since we’re savvy web developers, we rather use asynchronous processing these days. Instead of asking the browser to post back data and reload the whole page, we rather issue an Ajax call. This way we avoid page flickering and even the nasty long page scroll position stays the same. Ajax FTW! All today’s desktop browsers support this functionality as well. Great way of doing it then.
The whole client process probably changed according to our advanced functionality. We’d still have the master view with the list of all entities, but clicking on the Add new link will most probably present a modal dialog box with the details form instead of redirecting the user to a whole new page. In terms of usability and interface comprehension, this is a much better experience. Something similar is frequently used in Sharepoint 2010 these days. The process would work like this:
User clicks Add new link on the master view.
Your javascript dims the master view and displays a dialog box with the new entity form (details view).
User enters relevant data and clicks the Save link.
Your javascript issues an Ajax call that posts back data.
When everything goes according to the plan, server responds either with a PartialViewResult that holds visual representation of the newly created entity that can be appended to master page entity list, or JsonResult data that can be consumed for the same purpose (but you’ll have to manually transform JSON to visual HTML representation).
Your javascript closes the dialog box.
Master view is in full display again and your javascript adds the newly created entity to it’s list (while also providing some highlight animation).
It’s wiser to return a partial view since the same partial view can be used on the master view to display each entity item in the list, so they will be fully compatible and when you change your partial view, both functionalities still work as expected. Otherwise you’d have to change javascript code as well. Not DRY at all. This is our controller action now:
[HttpPost]
public ActionResult Add(Person instance)
{
if (!this.ModelState.IsValid)
{
// we'll see this in a bit
}
// save the new person instance and go back to master view
Person result = this.Service.Add(instance);
return PartialView("Person", result); // or Json(result)
}
So what do we do, when user enters incorrect data into the form that’s not valid? You can’t just return some other partial view, because javascript expects something else. You could of course put additional functionality on the client side that would detect different HTML being returned, but that’s very prone to errors. Think of changing the partial view. Any of the two. DRY again. The best thing would actually be to return a 400 HTTP response and provide the right result in it. Why is this better?
Because it will keep working even when you completely redesign your views.
Because it’s going to be much easier to distinguish between a successful results and an erroneous one on the client.
If you’re an Asp.net MVC developer it’s highly likely that you use jQuery on the client. Distinguishing success from an error cannot be easier:
$.ajax({
url: "Person/Add",
type: "POST",
data: $(this).serializeArray(), // provided this code executes in form.onsubmit event
success: function(data, status, xhr) {
// YAY! Process data
},
error: function(xhr, status, err) {
if (xhr.status == 400)
{
// this is our erroneous result
}
else
{
// some other server error must have happened (most probably HTTP 5xx)
}
}
});
To make things reusable on the server side you have two possible (and most obvious) ways of doing it:
Provide additional controller extension methods like PartialViewError, JsonError, etc. that will work very similar to their normal counterparts except they’ll also set the response status code to 400 (don’t forget to check whether this is an Ajax call, because if it’s not, don’t set status code).
Provide a custom exception and an exception action filter that handles it.
The first one is quite trivial so I’ve decided to do the latter. And since I don’t use the usual pattern of displaying in-place form validation errors it also suits my needs.
Let’s first look at the code of my custom exception. It’s called ModelStateException because I throw it on invalid model state and it has a constructor that takes model state and gets the errors automatically from it. This is the code of the exception:
/// <summary>
/// This exception that is thrown when there are model state errors.
/// </summary>
[Serializable]
publicclass ModelStateException : Exception
{
/// <summary>
/// Gets the model errors.
/// </summary>
public Dictionary<string, string> Errors { get; private set; }
/// <summary>
/// Gets a message that describes the current exception and is related to the first model state error.
/// </summary>
/// <value></value>
publicoverridestring Message
{
get
{
if (this.Errors.Count > 0)
{
returnthis.Errors.First().Value;
}
returnnull;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="ModelStateException"/> class.
/// </summary>
public ModelStateException() : base()
{
this.Errors = new Dictionary<string, string>();
}
/// <summary>
/// Initializes a new instance of the <see cref="ModelStateException"/> class.
/// </summary>
/// <param name="modelState">State of the model.</param>
public ModelStateException(ModelStateDictionary modelState)
: this()
{
if (modelState == null)
{
thrownew ArgumentNullException("modelState");
}
//this.ModelState = modelState;
if (!modelState.IsValid)
{
StringBuilder errors;
foreach (KeyValuePair<string, ModelState> state in modelState)
{
if (state.Value.Errors.Count > 0)
{
errors = new StringBuilder();
foreach (ModelError err in state.Value.Errors)
{
errors.AppendLine(err.ErrorMessage);
}
this.Errors.Add(state.Key, errors.ToString());
}
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="ModelStateException"/> class.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
public ModelStateException(string message, Exception innerException)
: base(message, innerException)
{
this.Errors = new Dictionary<string, string>();
this.Errors.Add(string.Empty, message);
}
/// <summary>
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with information about the exception.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
The exception action filter has to intercept ModelStateException exceptions and return the error in a predefined format, so the client’s able to uniformly consume it. This is the code that I’m using:
/// <summary>
/// Represents errors that occur due to invalid application model state.
Content = (filterContext.Exception as ModelStateException).Message,
ContentEncoding = Encoding.UTF8,
};
}
}
}
Reusable End Result
All our controller actions can now take advantage of this reusable functionality. The previously shown controller action now looks like this:
[HttpPost]
[HandleModelStateException]
public ActionResult Add(Person instance)
{
if (!this.ModelState.IsValid)
{
thrownew ModelStateException(this.ModelState);
}
// save the new person instance and go back to master view
Person result = this.Service.Add(instance);
return PartialView("Person", result);
}
Our client side functionality can now be packed into a simple application specific jQuery plugin that does ajax error handling and can be loaded as part of the general scripts on your master (as in master template) view:
This is the reusable model validation in Asp.net MVC applications using Ajax calls and jQuery on the client side.
HostForLIFE.eu ASP.NET MVC 5 Hosting HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality – beyond other hosting control panels – and ease of use, Plesk Control Panel is available only to HostForLIFE’s customers. They offer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.
Microsoft entered the arena of dynamic web sites with ASP (Active Server Pages) about a decade ago. ASP allowed you to “actively” change the web pages served to the client depending on your needs. ASP worked (and still works) very well for basic web design. It requires a Microsoft based IIS server and the necessary licenses.
ASP.NET is Microsoft’s next evolution for server driven web pages. Rather than amend ASP to add new functionality, ASP.NET is a complete overhaul providing a programming interface that allows developers familiar with Visual Basic and other Microsoft based client-server development tools to code for the internet.
ASP.NET is superior to ASP Classic. There are four main areas that make ASP.NET a much better choice for programmers. These four areas include: stability, performance, scalability and language support.
Stability
ASP is running under the inetinfo.exe (IIS) process space, making it susceptible to application crashes. This happens because the IIS needs to be stopped or restarted on a regular basis. The ASP.Net process is separate from inetinfo.exe, meaning that it is not susceptible to these types of application crashes. This means that the final product will be much more stable.
Compilation
ASP Classic is comprised of VBScript or Jscript interpreted at run-time which means each page has a specific performance hit due to line by line interpretation. The interpretation of the pages simply results in some inefficiency.
ASP.NET however compiles the code the first time it is accessed. The compiled code results in .NET classes housed within assemblies and allow subsequent page requests to be serviced with previously compiled code. ASP.NET therefore inherently provides a more secure and largely efficient rendering model by incorporating compilation and specifically the reuse of the compiled code. This ultimately means a better experience for the end user.
Scalability
With Classic ASP applications, components used by pages are fairly difficult to update, maintain or replace. In general updating a component in a running application will require the shutting down of IIS, replacement of the component and finally a restart of IIS.
ASP.NET was built to provide specific enhancements that allow scalable and efficient application updating. The ‘xcopy’ deployment model of .NET allows replacement of pages and components in real time and does not require a restart of the web server. If an update needs to be made to a current production application, developers can simply make the change and the infrastructure can account for that change the next time a request is made to the altered page or component. This means that content updates, fixes and enhancements to ASP.NET applications can be made in real time with little to no impact to the user base.
Language Support
ASP.NET supports full server side programming languages and not just scripting languages. Only VBScript and Javascript are available for scripting in ASP Classic where as, in ASP.NET there are no such restrictions. With ASP.NET several programming languages like C# and VB.NET are available to program in accordance to the developers preference where both of them can even be used in the same application. The benefits of using server side programming languages can be seen in the previously mentioned compilation of code and the fact that rich control sets and complex frameworks are available to applications. In summary, the language support of ASP.NET allows for the development of robust, feature rich applications with deep programmatic support.
There are two popular ways to upload and install Joomla on your website. The first (and simplest) is using the automated Joomla installation feature that your web hosting service provider may have activated on your “Control Panel”. The second way to upload Joomla and install it is to do it manually. This may seem kind of difficult initially, but it is very simple, if you understand how. In either of the two cases, you must have a web hosting account and be able to access it to be able to go ahead. You can’t use a free blog hosting account (Blogspot, etc) to do this. Below, I will give you a step by step blueprint for uploading and installing Joomla manually in 5 minutes or less. Here we go:
1. Download Joomla: The first step would be to of course download the latest Joomla installation package. You can do this by visiting Joomla.org and following the instructions to download the Joomla package.
2. Create a Joomla Installation Database: Now, login to your Joomla web hosting account and open the MySQL database creation and management program. A list of your databases and database user details are in the MySQL area of your Control Panel. Now, you should create a database and a username and password to go with it. Next, add the username to the database and give it all the privileges. This is simple as the interface is easy to follow. (But you can also watch the video instead if that is preferable to you.) This user ID and password and its database are what you will use to install Joomla on your website.
3. Upload Joomla: The next step is to determine where you want the Joomla installation to be and upload it to that. If you want to install Joomla on the main website/full domain name (eg mywebsite.com, etc), then you should go to the home directory and upload Joomla to it.
4. The Actual Joomla Installation: This is the simplest and most self-fulfilling part of the whole process. But you should also be careful not to make mistakes here or you may never be able to install the Joomla software correctly. You should also take note of the Joomla admin user name and password that you create during this process, to prevent losing access to your account. During the Joomla installation, you will put in such details as the name of the database that you created in step #2 and the username and password that you attached to it. You will put in the name and title of your website (great for Joomla SEO) and your email address to be used as the admin email in case you forget your Joomla admin login username and password. I would advise that you save all your login details in a secure place (like a random file on your computer or your brain [yeah, memorize it!] ) to avoid discomfort later on when you start the business of designing your Joomla website.
5. Finish: Yes, that’s it! You have just finished uploading and installing Joomla on your website! Now head on to the /administrator directory of the website where you installed Joomla (eg mywebsite.com/administrator ) and use the login ID and password that you created during the installation process to login to your Joomla website for the first time. How does it look in there?
The best WordPress plugins can enhance your blog with many exciting features to help expand your online presence, interact with your readers, and increase your blogging revenue. WordPress plugins are essential to take full advantage of the WordPress blogging platform, and these are some of the best WP plugins in a variety of categories. Take advantage of these WordPress plugins to enhance your WordPress blog with exciting new features.
WordPress Optimization
Optimization plugins help increase your natural traffic and create a better SEO presence.
Platinum SEO Pack
Greg’s High Performance SEO
WordPress SEO by Yoast
SEO Ultimate
WordPress Links
Link plugins help you manage and organize your links to provide a better reader experience and SEO optimization.
SEO Smart Link
Broken Link Checker
WP Render Blogroll Links
WordPress Comments
Comment plugins help you increase reader comments and interaction between readers with enhanced comment features.
IntenseDebate Comments
Disqus Comment System
Facebook Comments for WordPress
Comment Rating
WordPress Email Subscriptions
Email subscription plugins allow you to provide your readers with email subscriptions and send out newsletters.
MailChimp List Subscribe Form
Constant Contact for WordPress
AWeber Web Form Plugin
WP Email Capture
Subscribe2
WordPress Membership Communities
Membership community plugins for users allow you to build active communities to help grow your blog.
s2Member
Mingle
WP-Members
WordPress Social Media
Social media plugins allow your readers to promote your articles through a variety of social networks for free publicity.
Sexy Bookmarks
Simple Facebook Connect
WP Tweet Button
WordPress Forms
Forms plugins make it easier for your readers to contact you and more efficient for you to manage your inquiries.
Contact Form 7
Fast Secure Contact Form
Custom Contact Forms
Formiddable Forms
WordPress Polls
Polls plugins allow you to interact with your readers through polls and surveys.
SodaHead Polls
PollDaddy Polls and Ratings
WP Polls
WordPress Ratings
Ratings plugins allow bloggers to add reader rating systems to WordPress blogs.
Comment Rating
GD Star Rating
Star Rating for Reviews
WordPress Donations
Donation plugins are perfect if you want to request and process donations from your visitors.
PayPal Donations
Donation Can
Donate Plus
Mingle Donations Button
WordPress Videos
Video plugins make it easy to implement videos on your WordPress blog.
VideoPress
All-in-One Video Pack
WordPress Video Plugin
Stream Video Player
MediaElement.js
Embedded Video
WordPress Audio
Audio plugins help you provide the best quality audio and present it in a simple way to your listeners.
Audio Player
MediaElement.js – HTML5 Video & Audio Player
Audio Player Widget
Audio Link Player
WordPress Images and Galleries
Images and galleries plugins help you display your images or galleries in an interactive way for your viewers.
NextGen Gallery
Page Flip Image Gallery
WP Photo Album Plus
Flickr Photo Album
SEO Friendly Images
WordPress Health
Health plugins monitor the health of your WordPress installation to protect your WP site from security vulnerabilities, attacks, and spammers.
WP Security Scan
Akismet
WordPress Backups
Backup plugins help you automate the task of making regular backups of your WordPress site.
EZPZ One Click Backup
WordPress EZ Backup
XCloner – Backup and Restore
WordPress Translations
Translation plugins help you expand your international web presence with language translation features.
Global Translator
Google Ajax Translation
Transposh
qTranslate
Use these WordPress plugins to enhance your blog and increase your readership.