Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts

RegistrationForm With Modal Popup In MVC Using BootStrap

In this article i will show you how to design registration form using modal popup in mvc
write the code in your cshtml page
Example:-
Step1:- Take one button
<input type="button" value="Sumbit" id="btn1" />
Sterp2:-Wreite jquery code
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btn1").click(function()
            {
                $("#modalbox").modal("show")
            })
        })

    </script>

How To Declare CheckBox Different Ways In MVC

In this article i explain you how to declare checkbox different ways in mvc
We have diffrent overloaded versions in mvc for declaring checkbox

1st Form :-
    @Html.CheckBox("CheckBox1")
2nd Form :-
    @Html.CheckBox("CheckBox1",true)
3rd Form :-
    @Html.CheckBox("CheckBox1", new { id="chk1",value="option1"})
4rh Form :-
    @Html.CheckBox("CheckBox1", new Dictionary<string, object>() { { "id","chk1"} ,{"value","option"}})
5th Form :-
    @Html.CheckBox("CheckBox1", true, new { id="chk1",value="option1"})
6th Form :-
    @Html.CheckBox("CheckBox1", true, new Dictionary<string, object>() { {"id","chk1" },{"value","option1"} })

How To Declare TextArea Different Ways In MVC

In this article i explain you how to declare TextArea in mvc
1st Form :-TextArea with name
    @Html.TextArea("txtName")
2nd Form :-TextArea name and value
    @Html.TextArea("txtName","value")
3rd Form :-TextArea name,value and styles
    @Html.TextArea("txtName", new { id="txtId",style="background-color:green"})
4th Form :-TextArea using dictionary
    @Html.TextArea("txtAddress", new Dictionary<string, object>() { { "id", "txtAddress" }, { "class","class1"} })
5th Form :-TextArea name,value and id
    @Html.TextArea("txtName", "value", new { id="txtId",@class="class1"})
6th Form :-TextArea name,value , id and style using dictionary
    @Html.TextArea("txtName", "value", new Dictionary<string, object>() {{"id","txtId"},{"style","color:green"}})

How To Declare TextBox Different Ways In MVC

In this article i explain you how to declare textbox different ways in mvc
 1st Way:- textbox with name
         @Html.TextBox("txtName")
2nd Way :-textbox name and value
    @Html.TextBox("txtName","value")
3rd Way:-textbox name,value,id,maxlenth and size
    @Html.TextBox("txtName", "value", new { id="txt1",maxlenth="20",size="15"})
4th Way :-textbox name,value and currency 
    @Html.TextBox("txtName",15000,"{0:C}")

5th Way:-textbox name,value using dictionary 
    @Html.TextBox("txtName","value",new Dictionary<string,object>(){{"id","txt1"},{"maxlenth","15"},    {"size","20"},{"class","class1"}})

How To Declare ListBox Different Ways In MVC

In this article i explain you how to declare ListBox in mvc

    @using(Html.BeginForm())
    {
        List<SelectListItem> objSelectItem = new List<SelectListItem>()
        {
            new SelectListItem(){Text="Option1",Value="1"},
            new SelectListItem(){Text="Option2",Value="2"},
            new SelectListItem(){Text="Option3",Value="3"},
            new SelectListItem(){Text="Option4",Value="4"}
        };
        @Html.ListBox("ListBox1",objSelectItem)
    }

How To Declare ListBox Using ViewData In MVC

In this article i explain you how to declare ListBox Using ViewData in mvc.
    @using(Html.BeginForm())
    {
        List<SelectListItem> objSelectItem = new List<SelectListItem>()
        {
            new SelectListItem{Text="Option1",Value="1"},
            new SelectListItem{Text="Option2",Value="2"},
            new SelectListItem{Text="Option3",Value="3"},
            new SelectListItem{Text="Option4",Value="4"}
        };
        ViewData["ListBox1"] = objSelectItem;
        @Html.ListBox("ListBox1")    
    }

How To Declare DropDownList Different Ways In MVC

In this article i will explain you how to declare dropdownlist different ways
Step1:-
    @using (Html.BeginForm())
    {
        List<SelectListItem> objSelectItem = new List<SelectListItem>()
        {
            new SelectListItem{Text="Option1",Value="1"},
            new SelectListItem{Text="Option2",Value="2"},
            new SelectListItem{Text="Option3",Value="3"},
            new SelectListItem{Text="Option4",Value="4"}
        };
        @Html.DropDownList("DropDownList1",objSelectItem)
    }
2nd Way :-
  @Html.DropDownList("DropDownList1", new List<SelectListItem>()
{
    new SelectListItem{Text="Option1",Value="1"},
    new SelectListItem{Text="Option2",Value="2"},
    new SelectListItem{Text="Option3",Value="3"},
    new SelectListItem{Text="Option4",Value="4"}

})

How To Declare DropDownList Using ViewData In MVC

In this article i will explain you how to declare dropdownlist different ways in mvc
we are declaring dropdownlist  statically
Step1:-Using ViewData
    @using(Html.BeginForm())
    {
        List<SelectListItem> objListItem = new List<SelectListItem>();
        objListItem.Add(new SelectListItem() { Text = "Option1", Value = "opt1" });
        objListItem.Add(new SelectListItem() { Text = "Option2", Value = "otp2" });
        objListItem.Add(new SelectListItem() { Text = "Option3", Value = "opt3" });
        ViewData["DropDownList1"] = objListItem;
        @Html.DropDownList("DropDownList1")
    }
Second Way:-Using ViewData
    @using (Html.BeginForm())
    {
        List<SelectListItem> objSelectItem = new List<SelectListItem>()
        {
            new SelectListItem{Text="Option1",Value="opt1"},
            new SelectListItem{Text="Option2",Value="opt2"},
            new SelectListItem{Text="Option3",Value="opt3"},
            new SelectListItem{Text="Option4",Value="opt4"}
        };
       ViewData["DropDownList1"] = objSelectItem;
        @Html.DropDownList("DropDownList1","Select Option")
    }

What is caching in ASP.NET MVC and when to use it?

Caching is a most important aspect of high-performance web application. Caching provides a way of storing frequently accessed data and reusing that data. Practically, this is an effective way for improving web application’s performance.

What are advantages of caching in ASP.NET MVC?

These are following advantages of caching:-
1. Reduce hosting server round-trips
2. When content is cached at the client or in proxies, it cause minimum request to server.
3. Reduce database server round-trips
4. When content is cached at the web server, it can eliminate the database request.
5. Reduce network traffic
6. When content is cached at the client side, it also reduce the network traffic.
7. Avoid time-consumption for regenerating reusable content

What is the order of execution of filters in ASP.NET MVC?

All ASP.NET MVC filter are executed in an order. The correct order of execution is given below:

1.Authentication filters
2. Authorization filters
3. Action filters
4. Result filters

What are ASP.NET MVC Filters and Attributes?

Ans. ASP.NET MVC provides a simple way to inject your piece of code or logic either before or after an action is executed. This is achieved by decorating the controllers or actions with ASP.NET MVC attributes or custom attributes. An attribute or custom attribute implements the ASP.NET MVC filters (filter interface) and can contain your piece of code or logic. You can make your own custom filters or attributes either by implementing ASP.NET MVC filter interface or by inheriting and overriding methods of ASP.NET MVC filter attribute class if available.

What is Scaffolding In Asp.Net MVC ?

Scaffolding is a technique used by many MVC frameworks like ASP.NET MVC, Ruby on Rails, Cake PHP and Node.JS etc., to generate code for basic CRUD (create, read, update, and delete) operations against your database effectively. Further you can edit or customize this auto generated code according to your need.

Data Annotations in ASP.NET MVC

Data validation is a key aspect for developing web application. In Asp.net MVC, we can easily apply validation to web application by using Data Annotation attribute classes to model class. Data Annotation attribute classes are present in System.ComponentModel.DataAnnotations namespace and are available to Asp.net projects like Asp.net web application & website, Asp.net MVC, Web forms and also to Entity framework ORM models.

Action Methods In MVC

Controller actions are methods defined in the controller class and responsible to perform required operations on the user's inputs like as form values, query strings values etc. with the help of Model and passing the results back to the View. Asp.net MVC has the following built-in ActionResults Type and Helper methods:

Brief History Of ASP.NET MVC

Ans. Here is the list of released version history of ASP.NET MVC Framework with theirs features.

ASP.NET MVC1:-

1. Released on Mar 13, 2009
2. Runs on .NET 3.5 and with Visual Studio 2008 & Visual Studio 2008 SP1
3. MVC Pattern architecture with WebForm Engine
4. Html Helpers
5. Ajax helpers
6. Routing
7. Unit Testing