There are a quite a number of different workable methods to implementing
jquery and ASP.NET.  If you are comfortable with writing custom server
controls, then here is just one way:

1. For each control that uses jquery, add this to the OnPreRender event:

Page.ClientScript.RegisterClientScriptInclude("jquery",
"path/to/jquery.js");

This will only register the script once per page, and if no control needs
jquery, the script will not be referenced at all.

2. Have a document.ready function defined as appropriate.

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), this.ID,
"$(document).ready(function(){ do_stuff(); });", true);

3. For Ajax calls, set up an IHttpHandler to receive ajax requests in the
web.config

<httpHandlers>
<add verb="*" path="jQuery.ashx" type="AjaxHandler, AssemblyNameGoesHere"/>
</httpHandlers>

4. Build your IHttpHandler with this signature:

public class AjaxHandler : IHttpHandler {

public bool IsReusable{get{return false;}}
public void ProcessRequest(HttpContext context)
{
// Disable client-side caching on the ajax call.
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.Cache.SetExpires(new DateTime(2000, 1, 1));

// Get the data about the ajax call from the
// context.Request.QueryString and the 
// context.Request.Form collections, then:

do_something_based_on_ajax_call_data();

context.Response.Write(result);
context.Response.End();
}

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of shapper
Sent: Wednesday, November 21, 2007 3:45 PM
To: jQuery (English)
Subject: [jQuery] JQuery and ASP.NET.


Hello,

I want to use JQuery on my ASP.NET projects.

Consider the first example on the following page:
http://p.sohei.org/stuff/jquery/tablehover/demo/demo.html

I am trying to create a control to easy integrate JQuery into ASP.NET
pages ...
... and also register "commands" as seen in the page example I am
posting.

I would like to receive some advices on how to do this?
I am looking for JQuery advices on the best way to do this ...

Thanks,
Miguel

Reply via email to