|   Contact  

ASP.NET Whidbey FAQ


May 2004
Visits:

FAQ:

  • What is WebForm_DoPostBackWithOptions Well it is something new we created for Whidbey, it is a replacement for the old __doPostback javascript method that is richer in functionality, for instance this method supports client side validators, keeping scroll bar position, autopostback, and many more. Also this method is though in terms of extensibility for the future.
    We also added a server side way to generate the javascript call to this method using the Page.GetPostBackEventReference(options)
    It is not necesarily a replacement since we tried to keep backwards compatibility as much as possible (even when we said it was not supported to call directly __doPostBack, but instead use the Page.GetPostBackEventReference method), if you use the default options for instance, you dont use the new Maintain Focus or the autopostback features, then it will actually render the same __doPostBack call that we used in v1.X.
    This method is defined in WebForms.js which is now a resource inside System.Web.dll, and it is served using the new WebResource.axd handler.
    The thing that is really cool about WebResource.axd is that it alleviates many of the problems that we had in the past with the aspnet_clientfiles folder where we use to have to serve the client sript (.js) files that were needed for things like validators.

    In Whidbey we have many more scripts since we are trying to leverage a little bit more client side functionality, for instance GridView can now do sorting and paging without doing PostBack. This is done with a very cool feature that we have named Callbacks that I will talk later.
  • What is WebResource.axd and how can I use it WebResource.axd is a new Handler we are shipping to allow control and page developers to download resources that are embedded in an assembly. This is a very important scenario since control developers may need to include a javascript file (.js) or images (.jpg, .gif) for their controls.
    Previously they had to rely on copying the files inside a specific folder called aspnet_client that as created by asp.net to store client side files, but now you can just embbed the resource directly inside your dll and use Page.GetWebResourceUrl(Type, resourceId) and it will hand you back the correct Url to download your resource.
    This means that you can do things like: <script src='<PUT HERE THE STRING RETURNED BY Page.GetWebResourceUrl(typeof(YourControl), "YourScript.js")>'>
    or:
    <img src='<PUT HERE THE STRING RETURNED BY Page.GetWebResourceUrl(typeof(YourControl), "YourImage.jpg")>'>
    and it will just work. Another great advantage is that you can use localized assemblies for this and you will have the correct image or script localized.
  •  

Carlos Aguilar Mares © 2015