Ajax is not a
stand-alone language or technology. It is a technique that combines a set of
known technologies in order to create faster and more user friendly web pages. It is a client side technology.
AJAX is not a
new programming language , but it is a technique for creating better , faster,
and more interactive web application.
With AJAx ,
your Javascript can communicate directly
with the server , using the javascript
XML Http request objects. With this objectsn , your Javascript can trade
data with a web server , without reloading the page.
> The
XML HTTP Request Object
By using the XML Http request
object, a web developer can update a page with
data from the server after the
page has loaded !
> Scripting
with Script manager
The block of
code demonstraters the standard way of defining a class in ASP.NET AJAX. The internals of the client script library
are beyond the scope of this article, but in summary the common steps
necessary to creat a class based on the
ASP.NET Ajax script extensions are as followes:
• Register the namespace with ASP.NET
AJAX
• Create a constructor method
• Create the class proto type by
filling in the member methods and their functionality.
For an
example, is a consumer of your control was to set a property on an instance of
it like this
Public partial class_Default :
system.Web.UI.Page
{
Protected void page_load(object sender
, WEventArgs e)
{
This.MyCustomButton.AlertMessage=
“Hey, stop clicking me”!;
}
}
It would be intuitive to also be able to
intract with that control instance through script in the browser like this:
<Script
type =”text/Javascript ”>
Function get_text()
{
Var mb = $find(“Mycustom button”);
Var text = mb.get_AlertMessage();
// do something with the text
)
</script>
AJAX
and ScriptManager
Many developers ,
when first using ASP.NET , starts with the updatePanel control. If a script
manager control is included on the page and the updatepanel contains any
control, within updetepanel can be asynchronously through the facility of AJAX.
For an example, there is a new and fascinating
way to break script references using the UpdatePanel control and AJAX. In days
of old you would have added script to the page as a result of a full postback
such as this:
Protected void button1_Click (object sender ,
EventArgs e)
{
Page.ClientScript.registersatrtupscript(
This.GetType(), “muscript”,”alert(‘hello world!’);”);
}
But this new method can break under ASP.NET
AJAX Why? Because client script manager is not a control that understand
partial postbacks and partial rendering, and so script code registered with it will not be included in the page
response for a partial postback.
Instead , if you wanted the button to introduce
client script in to the page output , you would leverage the ScriptManager:
Protected void button1_click(object sender,
EventArgs e)
{
scriptManager,registerstartupscript(
this,this,GetType(),”myscript”,”alert(“hello worls”);”,true);
}
Udaipur City, Rajasthan, India