Useful Javascript/DOM Tools
DOMTool v1.1 | Muffin Research Labs
Here’s a great tool that will generate the necessary DOM scripts to create whatever HTML you want
http://muffinresearch.co.uk/code/javascript/DOMTool/
Comments off
Here’s a great tool that will generate the necessary DOM scripts to create whatever HTML you want
http://muffinresearch.co.uk/code/javascript/DOMTool/
Comments off
ASP.NET provides a nice way to avoid it’s full web control lifecycle. Why would you want to do this? Well, I found it most useful for doing AJAX work. For example, I have a javascript function I need to have ansynchronously call ASP.NET and return some data to update a HTML elements. In ASP Classic, PHP, Coldfusion, whatever, this is straightforward, the page gets called and some data is outputed. Using Prototypes Ajax.Request I would write the following,
function getSomeData(parameter1) {
var url = '/file_path/file_name.php';
var pars = 'param='+parameter1;
var myAjax = new Ajax.Request(
url, {
method: 'get',
parameters: pars,
onComplete: doSomethingWithData
}
);
}
With ASP.NET I could do the same with an ASPX page, but the request would go through the web control model, which adds overhead. So writing a custom HTTP Handler is one solution. Now there are a few ways to get this setup, but I will use the way I think is most straight-forward.
The first thing you’ll do is create a new class and place that class in the App_Code folder. Below is an example of a very simple class that returns data that will be consumed by the javascript function above. Within Visual Studio add a new class to your App_Code directory and call it, myhttphandler.cs.
using System;
using System.Web;
namespace MyHttpExtensions
{
public class HandlerExample : IHttpHandler
{
public void ProcessRequest(System.Web.HttpContext context)
{
HttpResponse response = context.Response;
response.write("Data to be use by javascript..data...data..");
}
public bool IsReusable
{
get {return true;}
}
}
}
After you have the class created, within Visual Studio you can create a file called a Generic Handler (file extension .ASHX), which you can put in your application directory. This file looks like,
< %@ WebHandler Language = "C#"
Class="MyHttpExtensions.HandlerExample" %>
The class name corresponds to the class you created in your App_Code folder. And there it is, you can now request a ASP.NET page which is very light-weight and avoids normal web control processing.
Comments off