• .NET Web

    How wrong custom ViewState handling may harm more than help

    September 25, 2007 Share
    As some of us have found last Friday this article in MSDN about how to store your ViewState in Session is totally wrong. Using the Reflector you can find very easily that ControlState will be erased if you access more than once PageStatePersister. The correct implementation should be:      PageStatePersister _pers;      protected override PageStatePersister PageStatePersister      {          get          {              if (_pers == null)                  _pers = new SessionPageStatePersister(this);              return _pers;          }      } How about overriding SavePageStateToPersistenceMedium / LoadPageStateFromPersistenceMedium? If you do this you should update your PageStatePersister or you will miss the ControlState once again. Example: protected override object LoadPageStateFromPersistenceMedium() {      object state = THESTATE;      if (state is Pair)      {          Pair statePair = (Pair)state;          PageStatePersister.ControlState =...

  • .NET Web

    Full support for LinqDataSource and WCSF ObjectContainerDataSource in RadGrid 5.0

    September 14, 2007 Share
    I'm pleased to announce that RadGrid 5.0 will have full support for LinqDataSource and WCSF ObjectContainerDataSource. The grid will be available for download in the beginning of the next week (17-18 September) and in the meantime you can check the attached examples:LinqDataSource exampleObjectContainerDataSource...

  • .NET Web

    ASP.NET AJAX Tips and Tricks

    By default ASP.NET AJAX will load and render your controls even if they do not need to be updated. Example:In this case the Panel marked as "Slow loading area" will be updated by default even on DropDownList1 selected index changed. What can we do to prevent this? You can set Panel1.Visible to true/false according to the current ajax request. Example: Enjoy! PS: Running example can be found here....

  • .NET Web

    Force update of an ASP.NET AJAX UpdatePanel using JavaScript

    Since the beginning of ASP.NET AJAX era I have seen very few examples on how to manually force update of an ASP.NET AJAX UpdatePanel using JavaScript and I have decided to post very simple approach how to do this. First of all you will need to create your own UpdatePanel which will inherit from the original ASP.NET AJAX UpdatePanel and will implement IPostBackEventHandler interface: Now you can call explicitly Update() method of the UpdatePanel: ... and that's it! :-) ... however we can extend this control with an event which will be raised on explicit updates: Now you can use the new UpdatePanel in your pages like this: Enjoy!

  • .NET Web

    Unwanted GET requests with latest IE and FireFox in case of empty img.src, script.src and link.href

    If you create or declare img and script element with empty src attribute or link element with empty href attribute you will receive unwanted GET request with latest FireFox. The problem with img elements exist even in IE 6/ IE 7 however the request will be to the application root. You can check all these using this simple example:<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">    protected void Page_Load(object sender, EventArgs e)    {    }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server">    <title>Untitled Page</title>    <script src=""></script>    <link href="" /></head><body>    <form id="form1" runat="server">        <img src="" />        <div>        </div>    </form></body></html>You should be extra careful...