Interview Tips Interview Tips, Interview Questions and Answers

13Oct/110

Additional security when calling JSON serialized services

A security feature of ASP.NET web services that are JSON serialized through the ASP.NET AJAX extensions is that they must be requested in a specific way. This is an important deterrent against your services being used in XSS attacks. Scott Guthrie has a great post providing detailed information on the particulars. It boils down to is two things:

  • The request must be an HTTP POST request
  • The request’s content-type must be: “application/json; charset=utf-8?

When you register and call a web service through ASP.NET AJAX’s ScriptManager, you may safely enjoy blissful ignorance of these requirements. The framework transparently handles everything for you.

However, if you want to use a third party AJAX framework to request the JSON serialized output, you may run into trouble due to these security features.

12Jun/110

Powerpacked new controls in Microsoft ASP.NET 3.5

DataPager - Controls like Gridview, Repeater exhibit the pagination behaviour. This is useful when display results return far too many records than an ideal web page height. A search may return countless records, but the web page size should not ideally go on and on depending on the number of records returned. For this, the feature of Page Numbers, OR Previous-Next feature at the bottom of the display results seem to be more ideal. For this purpose, the DataPager control has been introduced.

While using a ListView control, a DataPager control may be used along with it, to provide a paging functionality. The DataPager has a property called PagerControlId which is set to the ID of the ListView control. Simple!

ListView - This control is like an advanced Repeater control, and is as good as a GridView control in terms of features it has. It may be set to any standard data source like SQL, Oracle, Access, XML and even LINQ.

Say you want to display a matrix of values with 3 records per row, the ListView control is the ideal solution. The ListView settings may be made manually using the aspx page, OR may also be set using the Smart Tag feature to launch the properties dialog box.

ScriptManager - Every Ajax enabled page in ASP.NET that makes use of the Ajax Library needs to have a boss or a  manager that takes care of the internal Ajaxification process. All this is controlled by the ScriptManager control. Every page should have not more than one ScriptManager control. It takes care of the javascript functionalities, partial postbacks made by the web page by taking care of the XmlHttpRequest object from behind the scenes. More on Ajax, Read Here.

If the EnablePartialPostback property of the ScriptManager is set to false, the web page exhibits a full page postback.

ScriptManagerProxy - There might be a scenario where your master page and content page need to have separate ScriptManager controls. For such situations, the ScriptManagerProxy control comes to rescue. Here, the masterpage may contain the ScriptManager control, and the content page may use the ScriptManagerProxy control. However, internally, the ScripManagerProxy control communicates with the corresponding ScriptManager  class of the web page. The ScriptManagerProxy control actually transfers its set of responsibilities to the ScriptManager control.

UpdatePanel - This is the control that wraps all the controls that need to be partially posted back. A web page may comprise of several UpdatePanels. In case there is any event happening within the controls wrapped inside an UpdatePanel control, the entire page isn't posted back, rather only the contents within the UpdatePanel are posted back to the web server. If the partial postback property is to be avoided, set the ChildrenAsTriggers property of the UpdatePanel to false.

Further, the Triggers of an UpdatePanel may be used to set the application in such a way that the partial postback of the UpdatePanel may be invoked from controls that lie outside the UpdatePanel.

UpdateProgress - There are scenarios where a request may take time, an image may take time to load, a business logic may time to calculate, data may take time to load due to diversities in the source. In UpdatePanels, as postbacks are partial in nature, the browser's default progress bar does not appear. For avoiding any confusion to the end user, that a page process is going on in the background, the UpdateProgress control may be used. This is like a progress bar that shows to the end user that a process is going on. The progress may be set to any moving gif image as well, to enhance the look & feel of the web application.

2Jul/100

Flash Control for ASP.NET

Features

Works with .NET framework 2.0, 3.0 and 3.5

FlashControl supports all Flash properties :

Width, Height, Src, FlashVars, PluginsPage, Loop, Menu, Scale, BgColor, SwLiveConnect, Quality, Play, Base, Align, SAlign, WMode, AllowScriptAccess, AllowNetworking, SeamlessTabbing, Devicefont.
Ready for ASP.NET AJAX!
FlashControl fully works with ASP.NET AJAX UpdatePanel.

Supports communication between Flash and JavaScript.

FlashControl works with ASP.NET 2.0 Theme service and Skin files !
Full Visual Studio 2005 and 2008 Designer support :

Smart Tag!
Custom Designer
Custom Editors
Custom template
Web Resources
FlashControl provide a XHTML compliance mode ! The rendered code validates XHTML 1.0 strict in compliance with W3C web standards.

With FlashControl you can target specific HTML output : Internet Explorer Windows ( tag) and/or Netscape/Mozilla, IE MAC ( tag) or use Automatic browser detection (FlashControl will automatically choose to render tag or tag depending on browser capabilities).

29Jun/100

JavaScript & AJAX interview questions

1.  JavaScript is interpreted by _________

A.  Client

B.   Server

C.  Object

D.  None of the above

2.  Using _______ statement is how you test for a specific condition.

A.  Select

B.  If

C.  Switch

D.  For

3.  Which of the following is the structure of an if statement?

A.  if (conditional expression is true) thenexecute this codeend if

B.   if (conditional expression is true)execute this codeend if

C.  if (conditional expression is true)   {then execute this code>->}

D.  if (conditional expression is true) then {execute this code}

4.  How to create a Date object in JavaScript?

A.  dateObjectName = new Date([parameters])

B.   dateObjectName.new Date([parameters])

C.  dateObjectName := new Date([parameters])

D.  dateObjectName Date([parameters])

5.  The _______ method of an Array object adds and/or removes elements from an array.

A.  Reverse

B.   Shift

C.  Slice

D.  Splice

6.  To set up the window to capture all Click events, we use which of the following statement?

A.  window.captureEvents(Event.CLICK);

B.   window.handleEvents (Event.CLICK);

C.  window.routeEvents(Event.CLICK );

D.  window.raiseEvents(Event.CLICK );

7.  Which tag(s) can handle mouse events in Netscape?

A.  <IMG>

B.  <A>

C.  <BR>

D.  None of the above

8.  ____________ is the tainted property of a window object.

A.  Pathname

B.   Protocol

C.  Defaultstatus

D.  Host

9.  To enable data tainting, the end user sets the _________ environment variable.

A.  ENABLE_TAINT

B.   MS_ENABLE_TAINT

C.  NS_ENABLE_TAINT

D.  ENABLE_TAINT_NS

10.  In JavaScript, _________ is an object of the target language data type that encloses an object of the source language.

A.  a wrapper

B.   a link

C.  a cursor

D.  a form

12Jun/100

ASP.NET AJAX Interview Questions

The ASP.NET AJAX Interview Questions contains the most frequently asked questions in ASP.NET AJAX. These lists of questions will gauge your familiarity with the ASP.NET AJAX platform.
What is Ajax?
The term Ajax was coined by Jesse James Garrett and is a short form for "Asynchronous Javascript and XML". Ajax represents a set of commonly used techniques, like HTML/XHTML, CSS, Document Object Model(DOM), XML/XSLT, Javascript and the XMLHttpRequest object, to create RIA's (Rich Internet Applications).
Ajax gives the user, the ability to dynamically and asynchronously interact with a web server, without using a plug-in or without compromising on the user’s ability to interact with the page. This is possible due to an object found in browsers called the XMLHttpRequest object.
What is ASP.NET AJAX?
‘ASP.NET AJAX’ is a terminology coined by Microsoft for ‘their’ implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries.
Which is the current version of ASP.NET AJAX Control Toolkit?
As of this writing, the toolkit version is Version 1.0.20229 (if you are targeting Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005) and Version 3.0.20229 (if targeting .NET Framework 3.5 and Visual Studio 2008).
What role does the ScriptManager play?
The ScriptManager manages all ASP.NET AJAX resources on a page and renders the links for the ASP.NET AJAX client libraries, which lets you use AJAX functionality like PageMethods, UpdatePanels etc. It creates the PageRequestManager and Application objects, which are prominent in raising events during the client life cycle of an ASP.NET AJAX Web page. It also helps you create proxies to call web services asynchronously.
Can we use multiple ScriptManager on a page?
No. You can use only one ScriptManager on a page.
What is the role of a ScriptManagerProxy?
A page can contain only one ScriptManager control. If you have a Master-Content page scenario in your application and the MasterPage contains a ScriptManager control, then you can use the ScriptManagerProxy control to add scripts to content pages.
Also, if you come across a scenario where only a few pages in your application need to register to a script or a web service, then its best to remove them from the ScriptManager control and add them to individual pages, by using the ScriptManagerProxy control. That is because if you added the scripts using the ScriptManager on the Master Page, then these items will be downloaded on each page that derives from the MasterPage, even if they are not needed, which would lead to a waste of resources.
What are the requirements to run ASP.NET AJAX applications on a server?
You would need to install ‘ASP.NET AJAX Extensions’ on your server. If you are using the ASP.NET AJAX Control toolkit, then you would also need to add the AjaxControlToolkit.dll in the /Bin folder.
Note: ASP.NET AJAX 1.0 was available as a separate downloadable add-on for ASP.NET 2.0. With ASP.NET 3.5, the AJAX components have been integrated into ASP.NET.
Explain the UpdatePanel?
The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback.
Can I use ASP.NET AJAX with any other technology apart from ASP.NET?
To answer this question, check out this example of using ASP.NET AJAX with PHP, to demonstrate running ASP.NET AJAX outside of ASP.NET. Client-Side ASP.NET AJAX framework can be used with PHP and Coldfusion.
How can you cancel an Asynchronous postback?
Yes you can. Read my article over here.
Difference between Server-Side AJAX framework and Client-side AJAX framework?
ASP.NET AJAX contains both a server-side Ajax framework and a client-side Ajax framework. The server-side framework provides developers with an easy way to implement Ajax functionality, without having to possess much knowledge of JavaScript. The framework includes server controls and components and the drag and drop functionality. This framework is usually preferred when you need to quickly ajaxify an asp.net application. The disadvantage is that you still need a round trip to the server to perform a client-side action.
The Client-Side Framework allows you to build web applications with rich user-interactivity as that of a desktop application. It contains a set of JavaScript libraries, which is independent from ASP.NET. The library is getting rich in functionality with every new build released.
How can you debug ASP.NET AJAX applications?
Explain about two tools useful for debugging: Fiddler for IE and Firebug for Mozilla.
Can we call Server-Side code (C# or VB.NET code) from javascript?
Yes. You can do so using PageMethods in ASP.NET AJAX or using webservices.
Can you nest UpdatePanel within each other?
Yes, you can do that. You would want to nest update panels to basically have more control over the Page Refresh.
How can you to add JavaScript to a page when performing an asynchronous postback?
Use the ScriptManager class. This class contains several methods like the RegisterStartupScript(), RegisterClientScriptBlock(), RegisterClientScriptInclude(), RegisterArrayDeclaration(),RegisterClientScriptResource(), RegisterExpandoAttribute(), RegisterOnSubmitStatement() which helps to add javascript while performing an asynchronous postback.
Explain differences between the page execution lifecycle of an ASP.NET page and an ASP.NET AJAX page?
In an asynchronous model, all the server side events occur, as they do in a synchronous model. The Microsoft AJAX Library also raises client side events. However when the page is rendered, asynchronous postback renders only the contents of the update panel, where as in a synchronous postback, the entire page is recreated and sent back to the browser.
Explain the AJAX Client life-cycle events
Here’s a good article about the same.
Is the ASP.NET AJAX Control Toolkit(AjaxControlToolkit.dll) installed in the Global Assembly Cache?
No. You must copy the AjaxControlToolkit.dll assembly to the /Bin folder in your application.
Those were some frequently asked questions you should have knowledge about. In one of the coming articles, we will cover some more ASP.NET AJAX FAQ’s which were not covered in this article. I hope this article was useful and I thank you for viewing it.
2Mar/100

interviews on jQuery

Getting friendly with jQuery (A beginners guide + added auto TOC generation + text entry limit)
jQuery is a javascript library with rich API to manipulate DOM, event handling, animation and ajax interactions. The following are the essential features of jQuery that makes it so appealing for client side scripting.

Starting with JQuery
This article gives a brief introduction about what is Jquery and what can be done using JQuery.