updated topic discussion in Mvc

—Route table,Action filter ,validation  and Budling(how to use or call)

protected void Application_Start()

{

AreaRegistration.RegisterAllAreas();//Registers all the areas in ASP.NET MVC.

//GlobalFilters.Filters.Add(new HandleErrorAttribute());

FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) ;

RouteConfig.RegisterRoutes(RouteTable.Routes);

BundleConfig.RegisterBundles(BundleTable.Bundles);

//RegisterGlobalFilters(GlobalFilters.Filters);

}

///Route class defined in app_start folder .it is config file.

public class RouteConfig

{

public static void RegisterRoutes(RouteCollection routes)

{

routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);

 

// routes.MapRoute(

//   name: “Default”,

//   url: “{controller}/{action}/{id}”,

//                    defaults: new { controller = “Home”, action = “Index”, id = UrlParameter.Optional }

//);

routes.MapRoute(

name: “Default”,

url: “{controller}/{action}/{id}”,

defaults: new { controller = “Account”, action = “Login”, id = UrlParameter.Optional }

);

}

}

}

—Bundling class call global.asax but define in app_start folder .it is config file.

 

public class BundleConfig{

public static void RegisterBundles(BundleCollection bundles)

{

bundles.Add(new ScriptBundle(“~/bundles/jquery”).Include(

“~/Scripts/jquery-2.0.3.js”,

“~/Scripts/Aplication.js”,

“~/Scripts/jquery.inputmask-2.2.17.min.js”));

 

bundles.Add(new ScriptBundle(“~/bundles/jqgrid”).Include(

“~/Scripts/i18n/grid.locale-en.js”,

“~/Scripts/jquery.jqGrid.min.js”,

“~/Scripts/jquery.linq.min.js”));

bundles.Add(new ScriptBundle(“~/bundles/jqueryval”).Include(

“~/Scripts/jquery.validate*”));

 

// Use the development version of Modernizr to develop with and learn from. Then, when you’re

// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.

bundles.Add(new ScriptBundle(“~/bundles/modernizr”).Include(

“~/Scripts/modernizr-*”));

 

bundles.Add(new ScriptBundle(“~/bundles/bootstrap”).Include(

“~/Scripts/bootstrap.js”,

“~/Scripts/respond.js”));

 

bundles.Add(new StyleBundle(“~/Content/css”).Include(

“~/Content/bootstrap.css”,

“~/Content/Jq DatePicker/css/jquery.ui.datepicker.css”,

“~/Content/site.css”,

“~/Content/jquery.jqGrid/ui.jqgrid.css”,

“~/Content/Grid.css”,

“~/Content/themes/base/jquery-ui.css”));

 

bundles.Add(new ScriptBundle(“~/bundles/jqueryDatePicker”).Include(

“~/Scripts/jquery.ui.core.js”,

“~/Scripts/jquery.ui.widget.js”,

“~/Scripts/jquery.ui.datepicker.js”

));

 

}

}

—Action Filter

// Summary:

//     Represents the base class for filter attributes.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]

public abstract class ActionFilterAttribute : FilterAttribute, IActionFilter, IResultFilter

{

// Summary:

//     Initializes a new instance of the System.Web.Mvc.ActionFilterAttribute class.

protected ActionFilterAttribute();

 

// Summary:

//     Called by the ASP.NET MVC framework after the action method executes.

//

// Parameters:

//   filterContext:

//     The filter context.

public virtual void OnActionExecuted(ActionExecutedContext filterContext);

//

// Summary:

//     Called by the ASP.NET MVC framework before the action method executes.

//

// Parameters:

//   filterContext:

//     The filter context.

public virtual void OnActionExecuting(ActionExecutingContext filterContext);

//

// Summary:

//     Called by the ASP.NET MVC framework after the action result executes.

//

// Parameters:

//   filterContext:

//     The filter context.

public virtual void OnResultExecuted(ResultExecutedContext filterContext);

//

// Summary:

//     Called by the ASP.NET MVC framework before the action result executes.

//

// Parameters:

//   filterContext:

//     The filter context.

public virtual void OnResultExecuting(ResultExecutingContext filterContext);

}

–Use of View(also include validation,Beginform  ,jquery call and jquery call)

@model TypeSettingWeb.Models.RegisterViewModel

@{

ViewBag.Title = “Register”;

}

 

<h2>@ViewBag.Title.</h2>

 

@using (Html.BeginForm(“Register”, “Account”, FormMethod.Post, new { @class = “form-horizontal”, role = “form” }))

{

@Html.AntiForgeryToken()

<h4>Create a new account.</h4>

<hr />

@Html.ValidationSummary()

<div>

@Html.LabelFor(m => m.UserName, new { @class = “col-md-2 control-label” })

<div>

@Html.TextBoxFor(m => m.UserName, new { @class = “form-control” })

</div>

</div>

<div>

@Html.LabelFor(m => m.Password, new { @class = “col-md-2 control-label” })

<div>

@Html.PasswordFor(m => m.Password, new { @class = “form-control” })

</div>

</div>

<div>

@Html.LabelFor(m => m.ConfirmPassword, new { @class = “col-md-2 control-label” })

<div>

@Html.PasswordFor(m => m.ConfirmPassword, new { @class = “form-control” })

</div>

</div>

<div>

<div>

<input type=”submit” value=”Register” />

</div>

</div>

}

 

@section Scripts {

@Scripts.Render(“~/bundles/jqueryval”)

}

///Validation class

public class RegisterViewModel

{

[Required]

[Display(Name = “User name”)]

public string UserName { get; set; }

 

[Required]

[StringLength(100, ErrorMessage = “The {0} must be at least {2} characters long.”, MinimumLength = 6)]

[DataType(DataType.Password)]

[Display(Name = “Password”)]

public string Password { get; set; }

 

[DataType(DataType.Password)]

[Display(Name = “Confirm password”)]

[Compare(“Password”, ErrorMessage = “The password and confirmation password do not match.”)]

public string ConfirmPassword { get; set; }

}

–Actionlink uses

 

—            //

// Summary:

//     Returns an anchor element (a element) that contains the virtual path of the

//     specified action.

//

// Parameters:

//   htmlHelper:

//     The HTML helper instance that this method extends.

//

//   linkText:

//     The inner text of the anchor element.

//

//   actionName:

//     The name of the action.

//

//   routeValues:

//     An object that contains the parameters for a route.

//

// Returns:

//     An anchor element (a element).

//

// Exceptions:

//   System.ArgumentException:

//     The linkText parameter is null or empty.

public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues);

 
architecture using in mvc
json
repository

 

 

 

 

  2 comments for “updated topic discussion in Mvc

Leave a Reply