TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
AJAX Interview Questions and Answers
Mahesh Alle
May 21, 2019
176.5k
0
4
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Print
Other Artcile
In this article you will learn AJAX Interview Questions and Answers.
What is AJAX?
AJAX is an acronym for Asynchronous JavaScript and XML.
AJAX is a new technique for creating better, faster, and more interactive web applications.
With AJAX, a JavaScript script can communicate directly with the server, with the XMLHttpRequest object. With this object, a JavaScript can exchange data with a web server, without reloading the page.
AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of entire pages.
The AJAX technique makes Internet applications smaller, faster and more user-friendly.
What is "AsyncPostBackTimeout" Property?
AsyncPostBackTimeout Property specifies the time, in seconds, before an asynchronous postback timeout occurs if no response is received from the server.
The default value of this property is 90 (seconds).
We can also set the user defined error message using "asyncpostbackerrormessage" property (as shown in the code above) for the time out.
For example:
<
asp:ScriptManager
ID
=
"scriptManager1"
runat
=
"server"
AsyncPostBackErrorMessage
=
"We can not serve your request at this moment. Please try later."
AsyncPostBackTimeout
=
"120"
>
</
asp:ScriptManager
>
How to use Script Manager's "AsyncPostBackTimeout" at runtime?
If you have a Script Manager on the Master page and need to exceed AsyncPostBackTimeout only on specific page, then
Add this code line to the "Page_Load" event of your page.
This will set the AsyncPostBackTimeout to 2 minutes.
For example:
ScriptManager _scriptMan = ScriptManager.GetCurrent(
this
);
_scriptMan.AsyncPostBackTimeout = 120;
OR
ScriptManager.GetCurrent(
this
).AsyncPostBackTimeout = 120;
Is it possible to use a "FileUpload" control within the update panel?
Yes, it's possible.
But we need to use Postback triggers to upload the file.
Can you list some AJAX controls?
ScriptManager
ScriptManagerProxy
Timer
UpdatePanel
UpdateProgress
What is the "DisplayAfter" property in the UpdateProgress control?
The Displayafter property specifies how many seconds after loading the image that it needs to be displayed in the AJAX postback.
In other words, it gets or sets the value in milliseconds before the UpdateProgress control is displayed.
For example:
In the following example, the "Loading" text will be displayed after 5 sec.
<
asp:UpdateProgress
ID
=
"UpdateProgress1"
runat
=
"server"
DisplayAfter
=
"5000"
AssociatedUpdatePanelID
=
"UpdatePanel1"
>
<
ProgressTemplate
>
Loading...
</
ProgressTemplate
>
</
asp:UpdateProgress
>
How can we detect asynchronous partial page postbacks?
Use the "IsInAsyncPostBack" property of the "ScriptManager".
It returns a boolean value that can be used to check for partial page postbacks.
Which two methods are used for handling Cross-Domain AJAX Calls?
Cross-domain means the ability to manually or automatically access or transfer data between two or more differing security domains.
Cross-Origin Resource Sharing (CROS): Works with all HTTP verbs and most modern web browsers. Provides better support for error handling than JSONP.
JSON with padding (JSONP): It only works with HTTP GET verb and on legacy browsers.
What is the limitation with update panel?
Using update panel, you cannot validate outside controls.
For example:
There is a grid in an update panel and you want to validate the grid's field having a button outside the update panel. Validation will be executed but does not affect the page due to the update panel. So to solve this kind of problem, we have placed a button in another update panel.
What is "PageMethod" in ASP.Net AJAX?
The "PageMethods" feature enables the use of code-behind page methods on the client side.
PageMethods are implemented in a code behind file.
These are public static methods and are annoted with a [WebMethod] attribute.
The PageMethods can only be added to the page itself so don't try to add them to user controls or custom controls, it won't work.
Basically, all you need to do in order to use a PageMethod is to decorate your page method with the ScriptMethod and WebMethod attributes or only with the WebMethod attribute.
Another restriction is that the method has to be static (or else it won't work).
For example:
[WebMethod]
public
static
string
GetLabelText()
{
return
"Hello"
;
}
<script type=
"text/javascript"
>
function
InsertLabelData() {
PageMethods.GetLabelText(onSuccess, onFailure);
}
function
onSuccess(result) {
var
lbl = document.getElementById(
'lbl'
);
lbl.innerHTML = result;
}
function
onFailure(error) {
alert(error);
}
InsertLabelData();
</script>
More Interview Questions
Azure Interview Questions
ASP.NET MVC Interview Questions
C# interview questions
ASP.NET interview questions
Bootstrap interview questions
Html 5 interview questions
WCF interview questions and answers
WPF interview questions and answers
CSS interview questions and answers
Angularjs interview questions
SQL Server interview questions
ADO.NET interview questions and answers
Interview question on.NET framework or clr
Javascript interview questions
Interview questions for 2 year experience in SQL and C#
Important.NET interview questions and answers
Software Testing Interview Questions/
Dot.NET interview questions for experienced and fresher
SQL interview questions
C# interview questions and answers
jQuery interview question and answer with practices part 2
Python interview questions
AJAX
AJAX Interview Answers
AJAX Interview Questions
ASP.Net AJAX
AsyncPostBackTimeout
PageMethod
Recommended Free Ebook
Printing in C# Made Easy
Download Now!
Similar Articles