These are some of the Very Important Questions that you come across in your ASP.NET MVC or ASP.NET programming life.

1. How to check an element is visible or not using jQuery

Answer: Use Jquery : visible selector
if($("p").is(":hidden")){}
if($("div").is(":hidden")){}

2. How to select an element by name with jQuery?

Answer: This can be acheived by two ways.
WAY 1: by using jquery selector.
Example1: with id $("#foo") Selects all elements with the id="foo".
Example2: SELECTS ALL ELEMENTS $("*") Selects all elements
Example3: SELECTS ALL ELEMENTS WITH CLASS=BAR $(".bar") Selects all elements with class=bar.
Example4: SELECT ALL P ELEMENTS $("p") Selects all P elements
Example5: SELECT P ELEMENTS WITH BAR CLASS $("p.bar") Selects all elements with the id="foo".
WAY 2: GET ELEMENT BY NAME USING JAVASCRIPT AND PASS IT TO JQUERY selector = document.getElementsByName('nameOfElement'); element = $(selector); eg:- If you want to show or hide an element , then simply do like this element.hide() or element.show()

3. How to add text to an existing div with jquery

Answer: var a = "Hello USMTECHWORLD"; $('#dvscore').before(a);

4. What are the different development environments in your company?

Answer:
It is a very general question asked in any software company.Here they want to test whether you really know about software development process. Ok let us come into the question , what are different environments in your company. Normally all the companies will have following environments.


Development: QA or Staging Environment: Production:

5. How to add jquery file in View of ASP.Net MVC

Answer:
<script src="~/Scripts/jquery-1.10.2.js">
@Scripts.Render("~/Scripts/somesamples.js")
Inside the somesamples.js file, you can write all the jquery scripts related to your ASP.NET MVC view.

6. How do i use indentation in code tag of HTML?
public actionresult index()
{
Country objcountry = new Country();
objcountry.countrylist = PopulateCountries();
return View(objcountry);
}
In the above code i have used br tag to the code block,to display each line of the code in next line.

        public actionresult index()
        {
        Country objcountry = new Country();
        objcountry.countrylist = PopulateCountries();
        return View(objcountry);
        }
    
You can use the "pre" tag, which defines preformatted text. Text in a "pre" element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks. It is used when displaying text with unusual formatting, or some sort of computer code. And you will not need additional "br" tags.

7. Tell me the difference between design pattern,architecture and architecture style?

Answer:
By simply telling about this examples, you can easily understand about the difference between Design pattern, Architecure and Architecture style.
Design Patterns :- Decorator,Singleton, Factory,Adapter is Design patterns.
Architecture Pattern :- MVC,MVVM is architecture pattern.
Architecture Style:- REST,Service Oriented is architecture style.

8. How to set default route to an Area in ASP.NET MVC?

Answer:
You need to add DataToken to Default Route, in order to make your area as default route in route.config. for eg:- You have seperate area for login related files and want to be your default route during your application startup.

              routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { area= "Login", controller = "Login", action = "Index", id = UrlParameter.Optional }
            ).DataTokens.Add("area","Login");

9. How to get data from server side and display it on client side javascript using $.ajax get?

Scenario: For example, i have 2 files named Example1.aspx and Example2.aspx In example1.aspx i am saving currentdate in session.I need to get the current date in example2.aspx clientside. In example2.aspx, i have button as getcurrentdate.If i click button in example2.aspx,it should go to example1.aspx.cs file where i have stored currentdate in session and return back to example2.aspx. How to achieve? Solution:

        Example1.aspx.cs:-
        [System.Web.Services.WebMethod(EnableSession = true)]
        [System.Web.Script.Services.ScriptMethod(UseHttpGet = true)]
        public static string GetCurrentDate()
        {
        string ss= HttpContext.Current.Session["hdncurrentdate"].ToString();
        return ss;
        }
        public void SavingDateinSession()
        {
        Session["hdncurrentdate"]=datetime.now();
        }
Example2.aspx:- In ajax get request, you cannot pass text as datatype and get data from server (i.e example1.aspx) eventhough it is text data, because default datatype is json for both get and post request.
        <input type="button"  onclick="Fetchcurrentdate()" text=Fetchcurrentdate>
        function Fetchcurrentdate()
        {
        $.ajax({
        url: '/Example1.aspx/GetCurrentDate',
        type: 'GET',
        async: true,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: '{}',
        success: function (data) {
        currentdate = data.d;
        },
        error: function (xhr) {
        },
        complete: function (data) {
        }
        });
        }

10.How to backup a single table with its data from database in sql server?

Answer:
1.RIGHT CLICK DATABASE 2.SELECT TASKS=>GENERATE SCRIPTS 3.CHOOSE TABLE OR OBJECTS 4.SET SCRIPTING OPTIONS AND CLICK ADVANCED 5.SELECT TYPES OF DATA TO SCRIPT AND CHOOSE SCHEMA AND DATA 6.CLICK NEXT AND FINISH

11.What is Window LocalStorage?

Answer:
The localstorage properties allow to save key/value pairs in a web browser. The important point about localstorage is it stores the data with no expiration date.The data will not be deleted when the browser is closed and it will be available even on next day or next week when you view it on web browser. Eg:-//store localStorage.setItem("username","Muruga"); //retrieve localStorage.getItem("username"); //Muruga

12.What is Window SessionStorage?

Answer:
The sessionStorage stores data for only one session.The data is removed or deleted when the browser is closed. Eg:-//store sessionStorage.setItem("username","Shiva"); //retrieve sessionStorage.getItem("username"); //Shiva

13.What is Json.Parse?

Answer:
It means interpret or read the data given in the specific format (i.e JSON).So JSON.parse means it reads the string and converts that string to javascript object.The job of the parser is to convert the string into objects.
Let us understand this by this simple example,
Example:-
var str='{"name": "Shiva"}';
var obj=JSON.parse(str);
BEFORE PARSING:-
before parsing it is a string and you cannot access the data inside it
console.log(str.name) // prints "undefined"
AFTER PARSING:-
after parsing it becomes javascript object and you can access its properties and methods.So you get the name "Shiva" during printing of obj.name
console.log(obj.name) // prints "Shiva"