> Can some body write a simple example for xmlhttprequest ??
> I am only able to find the client side coding ,but not the server side
> coding....
Well it depends on what you want to do, with ASP.NET there are various
possibilities, if someone does a HTTP POST request with an XML document
in the request body then one way with .NET to read that is e.g.
XmlDocument requestXML = new XmlDocument();
requestXML.Load(Request.InputStream);
That way you get an XML DOM XmlDocument of the POSTed XML. You can use
any API .NET provides however on that InputStream, e.g. using an
Xml(Text)Reader is possible as well.
If you want to send XML back to the client then again there are lots of
ways to do that, you could for instance use an XmlTextWriter on
Response.Output e.g.
Response.ContentType = "application/xml";
XmlTextWriter xmlWriter = new XmlTextWriter(Response.Output);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("gods");
xmlWriter.WriteElementString("god", "Kibo");
xmlWriter.WriteElementString("god", "Xibo");
xmlWriter.WriteEndDocument();

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Vimal - 27 Apr 2006 18:32 GMT
Hi Martin,
I refered http://www.xmlhttprequest.org/
And in that there a code like the follwoing thing.... in client side
....
----------------------
request.open("GET", "myServerPage.aspx", true);
request.send();
----------------------
what i like to know is that what and how should i write the
myserverPage.aspx page (for the above example)
-- Vimal
Martin Honnen - 27 Apr 2006 18:49 GMT
> And in that there a code like the follwoing thing.... in client side
> ....
[quoted text clipped - 5 lines]
> what i like to know is that what and how should i write the
> myserverPage.aspx page (for the above example)
Well author that aspx page the same way you would author other aspx
pages, the client-side code makes an HTTP GET request to that URL with
the myServerPage.aspx page without passing anything in the querystring
nor with passing anything in the request body.
So there is no data passed in that myServerPage.aspx could process, it
simply needs to create a HTTP response.
Noone but you can tell what to do exactly in that page as it simply
depends on your needs, whether you want to return an XML document (see
my earlier answer on how to return that on the fly using XmlTextWriter),
whether you want to return some text, whether you want to return some
JSON data, whether you want to return some HTML.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Vimal - 27 Apr 2006 18:51 GMT
why i am asking for the example is i have a doubt.........if i call
like this(myServerPage.aspx) it will execute all the page code right ?
......
instead i want to execute a function which will return a xml document
as of now ....
so that i can further increase the functionality to get the data from a
data base and send that back to the clide as a XML document.
............ How can i differentiate the code in the aspx page to
identify whether the request is as "Autopost back request" or"
XMLHttprequest "?
---Vimal
Martin Honnen - 27 Apr 2006 19:08 GMT
> instead i want to execute a function which will return a xml document
> as of now ....
> so that i can further increase the functionality to get the data from a
> data base and send that back to the clide as a XML document.
Here is an example of a simple ASP.NET page sending back some XML
generated with XmlTextWriter
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">
void Page_Load() {
Response.ContentType = "application/xml";
XmlTextWriter xmlWriter = new XmlTextWriter(Response.Output);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("gods");
xmlWriter.WriteElementString("god", "Kibo");
xmlWriter.WriteElementString("god", "Xibo");
xmlWriter.WriteEndDocument();
}
</script>
You might also want to look into ASP.NET HTTP handlers as the proper
tool to process HTTP requests without the (possible overhead of the)
ASP.NET page model:
<http://samples.gotdotnet.com/quickstart/aspplus/doc/httphandlers.aspx>
> ............ How can i differentiate the code in the aspx page to
> identify whether the request is as "Autopost back request" or"
> XMLHttprequest "?
The same as with any request processed in an aspx page
if (IsPostBack) {

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/