Click here to Skip to main content
6,594,932 members and growing! (14,113 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Cookies License: The GNU General Public License (GPL)

How To Make Anthem Ajax Work With Url ReWriting

By 1anurag

How To Make Anthem Ajax Work With Url ReWriting
Javascript, CSS, HTML, ASP, ASP.NET, Ajax
Posted:24 Mar 2008
Views:13,898
Bookmarked:75 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 2.43 Rating: 3.12 out of 5
1 vote, 16.7%
1
1 vote, 16.7%
2
1 vote, 16.7%
3

4
3 votes, 50.0%
5

Introduction

Anthem Ajax is one of the best ajax library available around
to write Ajax without writing JavaScript in Asp.Net.
But attempting to combine it with Extensionless Url ReWriting
is quite a challenge.

You can download Anthem Ajax from here.
You can read more about the Url ReWriting Tool used from here.
The Form control used is an extension of this article.

Background

In the current web development scenario,
the two most desirable goodies are:
(1) Ajax: giving no postbacks, and
(2) UrlReWriting: Giving SEO Friendly, Beautiful Urls.
But it has been quite difficult to use both of them together.

The Ajax breaks down whenever there is
url of the form: http://foo.com/id/151.
To overcome this problem I tackled it with
a strategy to provide different views of the same
Url to the html form and to the Ajax FrameWork.

The Solution

Towards uniting Anthem Ajax with Smooth Urls,
my strategy was to provide different views of the same
Url to the html form and to the Ajax FrameWork.
I wanted the action attribute of the form
to have the Original RawUrl as its value.
While I wanted the Anthem Ajax framework to have
the ReWritten Simple Url as its value.

I created a new Form Class By Inheriting it from HtmlForm Class.
Then I Write original URL (URL without ReWriting)
in the name attribute of the form.
And In the action Attribute, the Raw Url
(Beautiful Url, As It Appears in the Address Bar).

Then, I made one change in the
anthem.js file of the Anthem Download.
I made the function Anthem_GetCallBackUrl return url
from form.name instead of form.action.

This solves the two problems:
(1) The Action attribute of the form will have
the Original beautiful Extensionless Url (Raw Url).

This will help to preserve the beautiful
Extensionless Url even after page PostBacks
( like those are caused by button clicks ).

(2) While the Name Attribute will have the ReWritten Real Url.
This will be supplied to the Anthem Framework,
making it to believe that it is working with Out any Url ReWriting :-)

Using the code

To See a LIVE DEMO, Simply run the Attached
Sample Web Site.

To Do URL ReWriting In A Project:

(1) Just include the DLLs in the Folder: ReWriting DLLs
(2) Use the Anthem Library ( the dll in the above folder )
Contained With This Project.
(3) And make your Web.Config As Shown
In the Attached Web.Config File.
(4) Instead of using the form tags in
the .aspx files, use the inherited form's tags.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPL)

About the Author

1anurag


Member
My name is Anurag Dwivedi.
I live in Noida, India.
Feel free to contact me
at topanurag@gmail.com.
Programming is my passion.
Currently I am doing problem shooting
for my parent organisation: http://convexdigital.com.
Wish Happy Programming To All The Readers Smile


Occupation: Software Developer (Senior)
Company: ConvexDigital Software Solutions
Location: India India

Other popular ASP.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Mar 2008
Editor:
Copyright 2008 by 1anurag
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project