Interview Q & A for Javascript.MVC and .Net

1) What is ASP.net ?
A) Asp .net is web application framework developed by microsoft to build dynamic web aaplication and web services.

2)what is framework ?
A)Framework is collection of classes.

3)What is web application ?
A)the application that access from the Web browser.

4)First .netframework introduce ?
A) year 2002 with 1.0 framwork.

5)What is controller ?
A)Controller is nothing but a class that is intherit from the base controller class and class can contains function.

6)What is View ?
A) view is display the result of controller method or give look to your application .

7)What is Model ?
A)Model is collection table table and its property.

8)How the MVC Work ?
A)The controller respond the URL request get the data from the model and hands it over to the view then view respond to the browser as output

9)What is viewdata and viewbag ?
A)Viewdata and viewbag is use to pass data from the controller to view ?

10)What is action method in MVC ?
A)Action is public methods within controller that responds to the URL request.

11)What is meaning of mutators ?
The methods that modify the array object is called mutators like push,pop,shift,unshif.

12)What is closures in javascript
A)Inner function access the varible and parameter of outer function is called closures or function within function is also called closures.

13)What is NonAction attribute in .MVC?
A)To restrict access public method from the controller,NonAction attribute is used

            [NonAction]
    EX : Public ActionResult Add()  //This action method that you don't want to access decored this                                                              //  method with [NonAction] attribute
           {
                     //Some code
            }

14)How to get coonection string from App.comfig file
A) string con=configirationManger.AppConfig["SqlConnection"].toString()

15) How to rename display field like dabase column name is name and in view you want that column header will be display like department name
A) go to that model and add display attributes like [display(name='deparmnet name's)]


16) How to use Group by query in linque
A) declare one class for couting

           public class department
{
                           public string name{get;set;}
                           public int  count{get;set;}
}
Controller class
public actionresult Index()
{
var department=entity.Users.Inclue("Department")
                                           .group by(x=>x.department.Name)
                                          .select(y=>new department{
                                           name=y.key,
                                         count=y.Count;}).tolist();
}

16)Cutom view engine  available for asp..net Mvc
A)SparkNHAML,Brail,SharpDOM

17)How to generate dropdown list in M.V.C
A) @html.drpodownfor("Department",new List<selectelistitem>{
new selectelistitem{text="India",value=1},
new selectelist{text="UA",value=2}},""SelecteListItem)


18)How to get the data from the database table and bind in dropdown list
A) first in controller get the list from the datase and pass to the view

    viewbag.list=new seletlist{entity.department.tolist(),"DepartmentId","DepartmentName")


IN view
@html.DropdownListfor(model=>model.department,viewbag.list as list<seleteListItem>)

Comments