CJ

The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

ASP.NET 2.0 & the new WebResource.axd handler

Posted by Clayton James on November 5, 2006

ASP.NET 2.0 provides some new Page Class methods that insert dynamic javascript into your .aspx page. This is the case for SetFocus method that is a new Page method that inherits the Control class.

You will notice that when you call the SetFocus method in a page and view the source of the rendered page a WebResource.axd handler and some javascript has attached itself.
<script src=”/Test/WebResource.axd?d=-C1iQIXP-aLieQ9wSoBAxg2&amp;t=632677431704275456″ type=”text/javascript”></script>

This method is defined in the WebForms.js file described below.
<!–
WebForm_AutoFocus(‘UserTextBox’);// –>
</script>

 

Took me a while to find a some decent content on the subject and Peter explains things very clearly.

 

By Peter A. Bromberg, Ph.D

“This method is defined in WebForms.js which is now an embedded resource inside System.Web.dll, and it is served using the new WebResource.axd handler. WebResource.axd alleviates many of the problems that are present in ASP.NET 1.1 with the asp.net script files folder where you used to have to serve the client script (.js) files that are required for things like validators. There are a number of other javascript embedded resources in System.Web. If you are curious what Microsoft have been doing, and you’d like to see them all download this text file.

In ASP.NET 2.0 there are many more scripts since they are leveraging more client side functionality, for example GridView can now do sorting and paging without doing a PostBack. This is all done with the new Script Callback mechanism.”

WebResource.axd
WebResource.axd is the new Handler that enables control and page developers to download resources that are embedded in an assembly. This is a valuable and welcome tool, since control developers may want to include a javascript file (.js) or images (.jpg, .gif) for their controls and there is now a built-in method to access these. So now you can do things like:
<script src='<PUT THE STRING RETURNED BY Page.GetWebResourceUrl(typeof(YourControl), “YourScript.js”)> HERE’>
Another advantage is that you can use localized assemblies and you will have the correct image or script localized based on the deployment.”

11 Responses to “ASP.NET 2.0 & the new WebResource.axd handler”

  1. parag said

    How webresource.axd work for the html page saved locally

  2. CJ said

    Hi Parag,

    Webresources.axd works with ASP.Net 2.0 architecture and .aspx pages.

    Html are pages do not have this functionality.

    CJ

  3. Jaya said

    Hi

    I’m facing problems with WebResources.axd in Security. I’m trying to access session from Profile_Personalize method to retrieve the session ID.

    Which ever page generates / uses WebResouce.axd, it is making the Session in the context to be null when loading the page.

    Do you have any reasons or any solution to it?

    Thanks!

  4. Hi,

    defaultfocus doesnt work for me though. I get this error on IE and FF

    WebForm_AutoFocus is not defined

    [Break on this error] WebForm_AutoFocus(‘UsernameTextbox’);// –>

    Thanks,
    Emily

  5. Satyam said

    Hi

    I’m facing problems with WebResources.axd in Security using acutetix software.
    when type the http://url/Webresouse.axd then run time error is occour how to handle with them

    Do you have any reasons or any solution to it?

    Thanks!

  6. lederrock said

    Of Using Free, From the Tower?To you pre, visitor to Thailand.Online marketing solution, ?treasure box feeling?.Patterns and retain lederrock, in their techniques will certainly help.Mangled by translators, Policy Discount Do.,

  7. hi,

    i am facing this issues webresource.axd javascript error in asp.net

    please give solution ..

  8. […] ASP.NET 2.0 & the new WebResource.axd handler « CJ – Nov 05, 2006 · February 9, 2007 at 9:53 pm. Hi Parag, Webresources.axd works with ASP.Net 2.0 architecture and .aspx pages. Html are pages do not have this functionality…. […]

  9. […] ASP.NET 2.0 & the new WebResource.axd handler « CJ – Nov 05, 2006 · ASP.NET 2.0 provides some new Page Class methods that insert dynamic javascript into your .aspx page. This is the case for SetFocus method that is …… […]

  10. concrete said

    What a stuff of un-ambiguity and preserveness of valuable familiarity regarding unexpected feelings.

  11. […] ASP.NET 2.0 & the new WebResource.axd handler « CJ – Nov 05, 2006 · ASP.NET 2.0 provides some new Page Class methods that insert dynamic javascript into your .aspx page. This is the case for SetFocus method that …… […]

Leave a comment