European ASP.NET MVC 4 and MVC 5 Hosting

BLOG about ASP.NET MVC 3, ASP.NET MVC 4, and ASP.NET MVC 5 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

ASP.NET MVC 6 Hosting - HostForLIFE.eu :: How to Authenticate HTML files with ASP.NET MVC ?

clock June 26, 2015 08:08 by author Peter

Today, let me explain about how to Authenticate HTML files with ASP.NET MVC. To Check Html URL is Authenticated or Not Using Asp.net/MVC using the following code:
Coding:
if (Request.RawUrl.ToLower().EndsWith(".html")) 

if (Request.Cookies[".ASPXAUTH"] != null) 

  string value = Request.Cookies[".ASPXAUTH"].Value; 
  if (value == null || value == "") 
  { 
     Response.Redirect("~/Account/LogOn"); 
  } 

else 

  Response.Redirect("~/Account/LogOn"); 

}

The .ASPXAUTH is the Form Authentication Cookies and Account is the Controller. The LogOn is the action. Next step, write the following code in webconfig section:
<buildProviders> 
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" /> 
<add extension=".htm" type="System.Web.Compilation.PageBuildProvider" /> 
</buildProviders> 

<handlers> 
<add name="HTML" path="*.html" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceT
ype="Unspecified" requireAccess="Script" /> 
<add name="HTM" path="*.htm" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceTyp
e="Unspecified" requireAccess="Script" /> 
</handlers>  

I hope it works for you! Happy coding.

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.



ASP.NET MVC 6 Hosting - HostForLIFE.eu :: How to Validate Input in ASP.NET MVC ?

clock June 18, 2015 08:37 by author Peter

When you develop an app, sometimes your requirements could be that you need to send HTML values from view to the controller. Sometimes, we tend to use HTML Editors to save lots of some information into the view. By default, ASP.NET MVC does not permit a user to submit the HTML content. thus let's have a look at how to submit your form with HTML content.

First step, Open Visual Studio, then choose "New Project", then choose ASP.NET MVC Apps.

Name it the project name, then click OK.

Now, select Internet Application, then click OK.

Next step, make a new Model
ValidateModel.cs
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace ValidateInputDemo.Models
{
    public class ValidateModel
    {
        public string description { get; set; }
    }
}

HomeController.cs
public ActionResult ValidateInput()
{
    return View();
}
[HttpPost]
public ActionResult  ValidateInput(string description)
{
    ValidateModel validateInputModel = new ValidateModel();
    validateInputModel.description = description;
    return View(validateInputModel);
}

Add a new method to your Controller

ValidateInput.cshtml
@model ValidateInputDemo.Models.ValidateModel
@{
       ViewBag.Title = "ValidateInput";
}
@using (@Html.BeginForm("ValidateInput","Home",
FormMethod.Post, new { @id = "form1", @enctype = "multipart/form-data" }))
{
    <label id="lblDescription">Description

     @Html.TextAreaFor(m=>m.description, new {@id="txtDescription",@name="description" })

    <input type="submit" id="bttn_Submit" />
}


You can see in the code above, there is a text area and a submit button, have a glance within the browser. Press F5.

You'll be able to see in the preceding screen, if you type one thing into the description and press Submit then nothing happens.

Now check the following example. Add HTML content into text area.

You'll get the error higher than. This error comes because this is often the security from ASP.NET MVC. For applications, a user cannot send HTML values to the controller, but sometimes we wish to send values to the controller. For resolving this issue, we've the ValidateInput(false) attribute. simply place this into your controller and have a look.
[HttpPost]
[ValidateInput(false)]
public ActionResult  ValidateInput(string description)
{
   ValidateModel validateInputModel = new ValidateModel();
   validateInputModel.description = description;
   return View(validateInputModel);
}

Now press F5. After filling in the HTML attribute press the submit button, you will never get an error. So when you want to work with HTML attributes in your app text area or textboxes, remember to use validateinpute(false) in your ActionMethod.

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.



HostForLIFE.eu Proudly Launches Drupal 7.37 Hosting

clock June 1, 2015 09:41 by author Peter

European Windows and ASP.NET Spotlight Hosting Partner in Europe, HostForLIFE.eu, has announced the availability of new hosting plans that are optimized for the latest update of the Drupal 7.37 hosting technology.

HostForLIFE.eu hosts its servers in top class data centers that is located in Amsterdam (NL), London (UK), Paris (FR), Frankfurt(DE) and Seattle (US) to guarantee 99.9% network uptime. All data center feature redundancies in network connectivity, power, HVAC, security, and fire suppression. All hosting plans from HostForLIFE.eu include 24×7 support and 30 days money back guarantee. The customers can start hosting our Drupal site on our environment from as just low €3.00/month only.

Drupal is an open source content management platform powering millions of websites and applications. Thousands of add-on modules and designs let you build any site you can imagine. Drupal 7.37 Includes bug fixes and small API/feature improvements only (no major new functionality); major, non-backwards-compatible new features are only being added to the forthcoming Drupal 8.0 release. If you are looking for the right Windows ASP.NET Hosting provider that support Drupal 7.37, we are the right choice for you.

The 7.37 update also includes fixed a regression in Drupal 7.36 which caused certain kinds of content types to become disabled if we were defined by a no-longer-enabled module, removed a confusing description regarding automatic time zone detection from the user account form (minor UI and data structure change), allowed custom HTML tags with a dash in the name to pass through filter_xss() when specified in the list of allowed tags, allowed hook_field_schema() implementations to specify indexes for fields based on a fixed-length column prefix (rather than the entire column), as was already allowed in hook_schema() implementations, fixed PDO exceptions on PostgreSQL when accessing invalid entity URLs, added a sites/all/libraries folder to the codebase, with instructions for using it and added a description to the "Administer text formats and filters" permission on the Permissions page (string change).

HostForLIFE have hosted large numbers of websites and blogs until now. Our clients come from diverse backgrounds from all sectors of the economy. HostForLIFE.eu clients are specialized in providing supports for Drupal for many years. We are glad to provide support for European Drupal 7.37 hosting users with advices and troubleshooting for our client website when necessary.

HostForLIFE.eu is a popular online Windows based hosting service provider catering to those people who face such issues. The company has managed to build a strong client base in a very short period of time. It is known for offering ultra-fast, fully-managed and secured services in the competitive market. Our powerful servers are especially optimized and ensure Drupal 7.37 performance. We have best data centers on three continent, unique account isolation for security, and 24/7 proactive uptime monitoring.

For more information about this new product, please visit http://hostforlife.eu/European-Drupal-737-Hosting

About HostForLIFE.eu
HostForLIFE.eu is an European Windows Hosting Provider which focuses on the Windows Platform only. HostForLIFE.eu deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

HostForLIFE.eu is awarded Top No#1 SPOTLIGHT Recommended Hosting Partner by Microsoft (see http://www.asp.net/hosting/hostingprovider/details/953). Our service is ranked the highest top #1 spot in several European countries, such as: Germany, Italy, Netherlands, France, Belgium, United Kingdom, Sweden, Finland, Switzerland and other European countries. Besides this award, we have also won several awards from reputable organizations in the hosting industry and the detail can be found on our official website.



ASP.NET MVC 6 Hosting - HostForLIFE.eu :: How to Bind the Checkboxlist from The Database?

clock May 21, 2015 09:55 by author Peter

In this article I will explain you about How to bind the Checkboxlist from the database. Let’s try to understand this with an example. We will be using Courses table in this example as shown in the following picture.

Write the following SQL scripts for creating Courses table and inserting data into it.
CREATE TABLE Courses (
  Course_ID int IDENTITY (1, 1) PRIMARY KEY,
  Course_Name varchar(50),
  Course_Duration int,
  IsSelected bit
)
INSERT INTO Courses (Course_Name, Course_Duration, IsSelected)
  VALUES ('ASP.NET', 45, 1)
INSERT INTO Courses (Course_Name, Course_Duration, IsSelected)
  VALUES ('C#', 45, 0)
INSERT INTO Courses (Course_Name, Course_Duration, IsSelected)
  VALUES ('VB.NET', 45, 1)
INSERT INTO Courses (Course_Name, Course_Duration, IsSelected)
  VALUES ('MVC', 45, 0)
INSERT INTO Courses (Course_Name, Course_Duration, IsSelected)
  VALUES ('JQuery', 45, 1)
INSERT INTO Courses (Course_Name, Course_Duration, IsSelected)
  VALUES ('WCF', 45, 0)

Now, add your connectionstring with name="con" in the web.config file.
Write the below code in the Model class.
Model(Users.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace MvcCheckBoxList.Models
{
    public class Users
    {
        public int Course_ID { get; set; }
        public string Course_Name { get; set; }
        public int Course_Duration { get; set; }
        public bool IsSelected { get; set; }
        public static List<Users> getUsers()
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select * from Courses", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            var users = new List<Users>(ds.Tables[0].Rows.Count);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                var values = row.ItemArray;
                var user = new Users()
                {
                    Course_ID = (int)values[0],
                    Course_Name = (string)values[1],
                    Course_Duration=(int)values[2],
                    IsSelected = (bool)values[3]
                };
                users.Add(user);
            }
            return users;
        }
    }
}

Write the following code in the Controller class.
Controller(UserController.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcCheckBoxList.Models;
using System.Data;
using System.Text;
namespace MvcCheckBoxList.Controllers
{
    public class UserController : Controller
    {
        public ActionResult UsersIndex()
        {
            List<Users> model = new List<Users>();
            model = Users.getUsers();
            return View(model);
        }
        [HttpPost]
        public ActionResult UsersIndex(List<Users> user)
        {
            if (user.Count(x => x.IsSelected) == 0)
            {
                ViewBag.msg = "You have not selected any Course";
                return View();
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("You have selected – ");
                foreach (Users usr in user)
               {
                    if (usr.IsSelected)
                    {
                        sb.Append(usr.Course_Name + ",");
                    }
                }
                sb.Remove(sb.ToString().LastIndexOf(","), 1);
                sb.Append(" Courses");
                ViewBag.msg = sb.ToString();
                return View(user);
            }
        }
    }
}

Write the following code in the View:
View(UsersIndex.cshtml):
@model List<MvcCheckBoxList.Models.Users>
@{
    ViewBag.Title = "Index";
  }
<h5 style="color:Red">@ViewBag.msg</h5>
@if (string.IsNullOrEmpty(ViewBag.msg))
{
    using (Html.BeginForm("UsersIndex", "User", FormMethod.Post))
    {
       for (int i = 0; i < Model.Count; i++)
        {
        @Html.CheckBoxFor(m => m[i].IsSelected)
        @Html.Label(Model[i].Course_Name);
        @Html.HiddenFor(m => m[i].Course_Name);
        @Html.HiddenFor(m => m[i].Course_ID)
        <br />
        }
<div>  <input type="submit" value="Submit!" /></div>
    }
}

And here is the output:

When you click on Submit button then corresponding selected items will show. 

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.

 

 



Free ASP.NET MVC 6 Hosting UK – HostForLIFE.eu :: How to Creating Routes with ASP.NET MVC 6

clock April 29, 2015 08:01 by author Peter

In this tutorial, I will show you how to create routes with ASP.NET MVC 6. When using MVC 6, you don’t create your Route collection yourself.

You let MVC create the route collection for you. And now, write the following code:
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
namespace RoutePlay
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }
        public void Configure(IApplicationBuilder app)
        {
            app.UseMvc();
        }
    }
}

The ConfigureServices() method is utilized to enroll MVC with the Dependency Injection framework built into ASP.NET 5. The Configure() system is utilized to register MVC with OWIN. This is what my MVC 6 ProductsController resembles:

Notice that I have not configured any routes. I have not utilized either tradition based or property based directing, yet I don't have to do this. If I enter the request “/products/index” into my browser address bar then I get the response “It Works!”:

When you calling the ApplicationBuilder.UseMvc() in the Startup class, the MVC framework will add routes for you automatically. The following code will show you, what the framework code for the UseMvc() method looks like:
public static IApplicationBuilder UseMvc([NotNull] this IApplicationBuilder app)
{
    return app.UseMvc(routes =>
    {
    });
}
public static IApplicationBuilder UseMvc(
    [NotNull] this IApplicationBuilder app,
    [NotNull] Action<IRouteBuilder> configureRoutes)
{
    // Verify if AddMvc was done before calling UseMvc
    // We use the MvcMarkerService to make sure if all the services were added.    MvcServicesHelper.ThrowIfMvcNotRegistered(app.ApplicationServices);
    var routes = new RouteBuilder
   {
        DefaultHandler = new MvcRouteHandler(),
        ServiceProvider = app.ApplicationServices
    };
     configureRoutes(routes);
     // Adding the attribute route comes after running the user-code because
    // we want to respect any changes to the DefaultHandler.
    routes.Routes.Insert(0, AttributeRouting.CreateAttributeMegaRoute(
        routes.DefaultHandler,
        app.ApplicationServices));
     return app.UseRouter(routes.Build());
}


The AttributeRouting.CreateAttributeMegaRoute() does all of the heavy-lifting here (the word “Mega” in its name is very appropriate). The CreateAttributeMegaRoute() method iterates through all of your MVC controller actions and builds routes for you automatically.
Now, you can use convention-based routing with ASP.NET MVC 6 by defining the routes in your project’s Startup class. And here is the example code:
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Routing;
using Microsoft.Framework.DependencyInjection;
namespace RoutePlay
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }
       public void Configure(IApplicationBuilder app)
        {
            app.UseMvc(routes =>
            {
                // route1
                routes.MapRoute(
                    name: "route1",
                    template: "super",
                    defaults: new { controller = "Products", action = "Index" }
                );
                // route2
                routes.MapRoute(
                    name: "route2",
                    template: "awesome",
                    defaults: new { controller = "Products", action = "Index" }
                );
            });
        }
    }
}


I hope this tutorial works for you!

Free ASP.NET MVC Hosting
Try our Free ASP.NET MVC Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.



Free ASP.NET MVC Hosting - HostForLIFE.eu :: HTML Helper For Image (@Html.Image): Developing Extension in MVC

clock April 16, 2015 08:42 by author Peter

Today I worked on a project wherever i'm needed to show a picture on the web page with ASP.NET MVC. As you recognize there's not a hypertext markup language Helper for pictures yet. check out the following screen, we will not see a picture here:

Before proceeeding during this article, let me share the sample data source here:

Data Source & Controller

View

As in the above image, the first one (@Html.DisplayFor…) is generated by scaffolding on behalf of me (marked as a comment within the above view) and the second one is an alternative that may work. So, we do not have a hypertext markup language helper to manage pictures exploitation Razor syntax! We will develop an extension method for this that will allow us to work with pictures. Let's start.

Now, Add a class file using the following code: using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication8.Models
{   
public static class ImageHelper
    {
        public static MvcHtmlString Image(this HtmlHelper helper, string src, string altText, string height)
        {
            var builder = new TagBuilder("img");
          builder.MergeAttribute("src", src);            builder.MergeAttribute("alt", altText);
            builder.MergeAttribute("height", height);
            return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
        }
    }
}


The above "Image" function has the "MvcHtmlString" type and can settle for a four-parameter helper (helper sort "image"), src (image path), altText (alternative text) and height (height of image) and will return a "MvcHtmlString" type. In the view, comment-out the last line (HTML style approach) and use the new extended technique for the image, as in:

Note: Please note to use "@using MvcApplication8.Models" namespace on every view page to enable this new HtmlHelper. If you set a breakpoint on the extension method then you'll notice that the method returns the exact markup that we need.

Free ASP.NET MVC Hosting

Try our Free ASP.NET MVC Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.



ASP.NET MVC 6 Hosting Italy - HostForLIFE.eu :: How to POST JSON Data using AJAX, AngularJS and Spring MVC?

clock March 20, 2015 07:44 by author Peter

This sample shows the code that is utilized to post the JSON information to the server utilizing AngularJS $http service based on AJAX POST protocol in MVC. It additionally shows the capacity of AngularJS dependency injection which is used to inject $http service to the controller as it is initiated.

The $http administration is a center Angular administration that encourages communication  with the remote HTTP servers via the browser's XMLHttpRequest object or via JSONP. The detailed article on $http service could be found on AngularJS $http page.

Pay consideration on Spring MVC controller strategy where @RequestBody is utilized. One needs to make a Domain item mapping to JSON. Additionally, simply making the space object won't do. One needs to include Jackson libraries in the classpath. Otherwise, 415 error would keep haunting.

$http Service & Related Code
Let’s write the following code to  create JSON object:
var helloAjaxApp = angular.module("helloAjaxApp", []);
helloAjaxApp.controller("CompaniesCtrl", ['$scope', '$http', function($scope, $http) {    $scope.companies = [
                                    { 'name':'Infosys Technologies',
                                                'employees': 125000,
                                                'headoffice': 'Bangalore'},
                                                { 'name':'Cognizant Technologies',
                                                  'employees': 100000,
                                                  'headoffice': 'London'},
                                                  { 'name':'Peter',
                                                  'employees': 115000,
                                                  'headoffice': 'London'},
                                                  { 'name':’IT Support',
                                                  'employees': 150000,
                                                  'headoffice': ' London '},                                                              
                                    ];        
                $scope.addRowAsyncAsJSON = function(){                                                        
$scope.companies.push({ 'name':$scope.name, 'employees': $scope.employees, 'headoffice':$scope.headoffice });
                                // Writing it to the server
                                //                           
                                var dataObj = {
                                name : $scope.name,
                                employees : $scope.employees,
                                headoffice : $scope.headoffice
                                };            
                                var res = $http.post('/savecompany_json', dataObj);
                                res.success(function(data, status, headers, config) {
                                $scope.message = data;
                                });
                                res.error(function(data, status, headers, config) {
                                alert( "failure message: " + JSON.stringify({data: data}));
                                });                          
                                // Making the fields empty
                                //
                                $scope.name='';
                                $scope.employees='';
                                $scope.headoffice='';
                };
}]);

Java Controller Code
saveCompany_JSON method which is called from $http service using POST method type.  
@RequestBody Company company that represents the fact that request is parsed using Jackson library and passed as Company object.                                   
@RequestMapping(value = "/angularjs-http-service-ajax-post-json-data-code-example", method = RequestMethod.GET)
public ModelAndView httpServicePostJSONDataExample( ModelMap model ) {
                return new ModelAndView("httpservice_post_json");
}
@RequestMapping(value = "/savecompany_json", method = RequestMethod.POST)  
public  @ResponseBody String saveCompany_JSON( @RequestBody Company company )   {                                  

//

// Code processing the input parameters
//           
return "JSON: The company name: " + company.getName() + ", Employees count: " + company.getEmployees() + ", Headoffice: " + company.getHeadoffice();
}                                                                                             
Java Code for Company Object (Domain object)
package com.vitalflux.core;
public class Company {  
                private String name;
                private long employees;
                private String headoffice;
                public String getName() {
                                return name;
                }
                public void setName(String name) {
                                this.name = name;
                }
                public Long getEmployees() {
                                return employees;
                }
                public void setEmployees(Long employees) {
                                this.employees = employees;
                }
                public String getHeadoffice() {
                return headoffice;
                }
                public void setHeadoffice(String headoffice) {
                                this.headoffice = headoffice;
                }
}                          
                                                               

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.

 



ASP.NET MVC 6 Hosting UK - HostForLIFE.eu :: How to Search Records with Ajax in ASP.NET MVC ?

clock March 13, 2015 07:17 by author Peter

Today, I will tell you about how to search records 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.
$(document).ready(function () {
    $('#btnSearch').on('click', function () {
        var getkey = $('#txtSearch').val();
        $.ajax({           
        type: 'POST',
            contentType: 'application/json; charset=utf-8',
            url: 'Home/Search',
            data: "{ 'searchKey':' " + getkey + "' }",
            success: function (data) {
                BindData(data);
            },            
            error: function (data) {
                alert('Error in getting result');
            }
        });
   });
}); 
function BindData(data) {
    var ulList = '<ul>';
    var resultType = ["FirstName", "LastName", "Position"];
    $.each(data, function (i, d) {
        ulList += '<li class="SeachType">' + resultType[i] + '</li>';
        if (d.length > 0) {
            $.each(d, function (key, value) {
                ulList += '<li>' + value.FirstName + ' - ' + value.LastName + ' - ' + value.Position + '</li>'
            });
        } else {            
        ulList += '<li><span class="red">No Results</span></li>';
        }
    });
    ulList += '</ul>'
    $('#divList').html(ulList);
}

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.



HostForLIFE.eu Launches New Data Center in Frankfurt (Germany)

clock March 10, 2015 12:00 by author Peter

HostForLIFE.eu, a leading Windows hosting provider with innovative technology solutions and a dedicated professional services team proudly announces new Data Center in Frankfurt (Germany) for all costumers. HostForLIFE’s new data center in Frankfurt will address strong demand from customers for excellent data center services in Europe, as data consumption and hosting services experience continued growth in the global IT markets.

The new facility will provide customers and our end users with HostForLIFE.eu services that meet in-country data residency requirements. It will also complement the existing HostForLIFE.eu. The Frankfurt (Germany) data center will offer the full range of HostForLIFE.eu web hosting infrastructure services, including bare metal servers, virtual servers, storage and networking.

HostForLIFE.eu expansion into Frankfurt gives them a stronger European market presence as well as added proximity and access to HostForLIFE.eu growing customer base in region. HostForLIFE.eu has been a leader in the dedicated Windows & ASP.NET Hosting industry for a number of years now and we are looking forward to bringing our level of service and reliability to the Windows market at an affordable price.

The new data center will allow customers to replicate or integrate data between Frankfurt data centers with high transfer speeds and unmetered bandwidth (at no charge) between facilities. Frankfurt itself, is a major center of business with a third of the world’s largest companies headquartered there, but it also boasts a large community of emerging technology startups, incubators, and entrepreneurs.

Our network is built from best-in-class networking infrastructure, hardware, and software with exceptional bandwidth and connectivity for the highest speed and reliability. Every upstream network port is multiple 10G and every rack is terminated with two 10G connections to the public Internet and two 10G connections to our private network. Every location is hardened against physical intrusion, and server room access is limited to certified employees.

All of HostForLIFE.eu controls (inside and outside the data center) are vetted by third-party auditors, and we provide detailed reports for our customers own security certifications. The most sensitive financial, healthcare, and government workloads require the unparalleled protection HostForLIFE.eu provides.

Frankfurt (Germany) data centres meet the highest levels of building security, including constant security by trained security staff 24x7, electronic access management, proximity access control systems and CCTV. HostForLIFE.eu is monitored 24/7 by 441 cameras onsite. All customers are offered a 24/7 support function and access to our IT equipment at any time 24/7 by 365 days a year. For more information about new data center in Frankfurt, please visit http://hostforlife.eu/Frankfurt-Hosting-Data-Center

About HostForLIFE.eu
HostForLIFE.eu is an European Windows Hosting Provider which focuses on the Windows Platform only. HostForLIFE.eu deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

HostForLIFE.eu is awarded Top No#1 SPOTLIGHT Recommended Hosting Partner by Microsoft (see http://www.asp.net/hosting/hostingprovider/details/953). Our service is ranked the highest top #1 spot in several European countries, such as: Germany, Italy, Netherlands, France, Belgium, United Kingdom, Sweden, Finland, Switzerland and other European countries. Besides this award, we have also won several awards from reputable organizations in the hosting industry and the detail can be found on our official website.



ASP.NET MVC 6 Hosting Germany - HostForLIFE.eu :: How to Display Empty Data Text in WebGrid in ASP.NET MVC

clock March 6, 2015 06:57 by author Peter

In this case we disclose that how to show Empty Data Text in webgrid in MVC with ASP.NET.

There is no facility in webgrid to show empty datatext automatically, so we need to manually write or characterize the code for this.

Let's see a simple tips that demonstrates to show Empty Data or unfilled information message in ASP.NET MVC WebGrid by utilizing WebGrid web helper class. Here in this post we will check the  model in the event that it  has no data then show a message, like the EmptyDataText property of the ASP.NET GridView.

To utilize the WebGrid web assistant as a part of MVC application, you need to first make an article reference to the WebGrid class and utilize the GetHtml() method that renders the grid. To use the WebGrid web helper in mvc application, you have to first create an object reference to the WebGrid class and use the GetHtml() method that renders the grid.
@{
                Var grid=new WebGrid(Model);
@grid.GetHtml();
}
To Display an Empty Data Text in Webgrid when the Model has no data or no record, just you have to write  following one:
@if(Model.Count>0)
@{
Var grid=new WebGrid(Model);
@grid.GetHtml();
}
Else
<p>No Record Found</p>
}

I hope this tutorial works for you!

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.



About HostForLIFE.eu

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 offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in