Interview questions for 3-6 years experienced on .net


Recently i attended one cmmi level 5 mnc for 3+ experience.asp.net mvc and asp.net interview questions posted here.some of the questions what i remembered.please provide answers that will be helpful to others.

1.how do return partial view in controller?
2.what is difference between viewdata and view bag?
3.how to validate using data annotation fistname not be blank and
minimu 5- maximum 50 characters only allowed.


public class order
{
public int order id;
public string username;
public string firstname;
public string lastname;
}

4.create json structure for

public class order
{
public int order id;
public string username;
public bool active;
}

5.what is difference between hyperlink and link button?
6.where private assembly stored in asp.net?
7.which assembly used for localised resources?
8.postback=true for
a.dropdownlist
b.gridview
c.button
d.all the above
9.how to write a query for to get id,name,managerid,manager name it will have table employee
id int
name varchar(20)
managerid int
10.how to improve performance a table consits of 1000 records to select id,name,sal where designation = somecondition?
11.how to get 3 chatacters of a given telephone number?


Comments

Author: Aswini Aluri08 Dec 2013 Member Level: Silver   Points : 3

5.what is difference between hyperlink and link button?

Ans:The hyperlink will not postback to the servver.it will post a simple request to the server for the url set as navigate url.but link button works exactly as button hyperlink doesn't have an onclick event.

if you need to do any operation with data that's on the page you will have to use a LinkButton (or a Button), but if you just need to redirect the user to somewhere else go for an HyperLink (You will avoid half roundtrip!).

Author: Aswini Aluri08 Dec 2013 Member Level: Silver   Points : 3

6.where private assembly stored in asp.net?

Ans: private assembly's are stored in application directory or sub -directory beneath.
7.which assembly used for localised resources?
in Satelite Assembly

9Ans. select * from Employee

Author: Phagu Mahato21 Dec 2013 Member Level: Gold   Points : 10

In this response I am posting Detail answer for QNo 2
ViewBang and ViewDate are used for the same purpose.They are used to pass data from controllers to view. When we assign any data or object to them they are accessible in views. Let us see what is difference and similities between them.

ViewBang and ViewDate:

ViewBang and ViewDate are used for the same purpose.They are used to pass data from controllers to view. When we assign any data or object to them they are accessible in views.
ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.

Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view.

It's life also lies only during the current request.

If redirection occurs then it's value becomes null.

It doesn't required typecasting for complex data type.

ViewDate:

ViewData is a dictionary object that is derived from ViewDataDictionary class.

ViewData is used to pass data from controller to corresponding view.

It's life lies only during the current request.

If redirection occurs then it's value becomes null.

It's required typecasting for complex data type and check for null values to avoid error.


Similarities between ViewBag & ViewData :

Helps to maintain data when you move from controller to view.
Used to pass data from controller to corresponding view.
Short life means value becomes null when redirection occurs. This is because their goal is to provide a way to communicate between controllers and views. It's a communication mechanism within the server call.

Difference between ViewBag & ViewData:

ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys.
ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.
ViewData requires typecasting for complex data type and check for null values to avoid error.
ViewBag doesn't require typecasting for complex data type.

ViewData is a dictionary of objects and they are accessible by string as key.Example code is like this:

ViewBag & ViewData Example:


public ActionResult Index()
{
ViewBag.Name = "Phagu Mahato";
return View();
}

public ActionResult Index()
{
ViewData["Name"] = "Phagu Mahato";
return View();
}

public ActionResult Index()

{

var Languages = new List string

{

"C",


"C#",

"Java"

};
ViewData["Languages"] = Languages;

return View();

}

Another example

public class HomeController : Controller
{
public ActionResult Index()
{
var emp = new Employee
{
EmpID=Em1,
Name = "Deepak Kumar ",
Salary = 4000,
Address = "New Delhi"
};
ViewData["emp"] = emp;
ViewBag.Employee = emp;
TempData["emp"] = emp;
return View(); }
}

Author: Ritesh19 Feb 2014 Member Level: Bronze   Points : 2

Question 11: How to get 3 chatacters of a given telephone number

Answer:
firstTwoDigits = number.ToString().Substring(0,2);
int.Parse(firstDigit)
int.Parse(firstTwoDigits)



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: