Home Contact RSS

Some useful UpdatePanel extensions

I want to share some pretty basic and useful UpdatePanel control extensions with you. Method names are self explaining so I will not go deep in details.

public static void AlertOnLoad(this UpdatePanel updatePanel, string key, string message)
{
    message = message.Replace("'", "\'").Replace("\r\n", "").Replace("\n", "");
    message = "alert('" + message + "');";
    AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(updatePanel, updatePanel.GetType(), key, message, true);
}

public static void RedirectOnLoad(this UpdatePanel updatePanel, string key, string url)
{
    url = "top.location.href = '" + url + "';";
    AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(updatePanel, updatePanel.GetType(), key, url, true);
}

public static void OpenWindowOnLoad(this UpdatePanel updatePanel, string key, string url)
{
    url = "window.open('" + url + "');";
    AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript(updatePanel, updatePanel.GetType(), key, url, true);
}

ASP.NET AJAX 4.0 CodePlex Preview 1

ASP.NET AJAX 4.0 Preview 1 was released on July 21.

This release contains a preview version of the following features (that are also described in our Roadmap document: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14924):

* Client-side template rendering
* Declarative instantiation of behaviors and controls
* DataView control
* Markup extensions
* Bindings

One good news for JSON lovers, this is from release notes:

In the next version of ASP.NET AJAX, we plan on enabling new client-side data scenarios for both page and component developers. You will be able to get JSON data from the server and present it as HTML on the client in a highly manageable and performant way.

You may see the CodePlex project at http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=15511