Click here to Skip to main content
Email Password   helpLost your password?

Introduction

I was very interested in reading the article, Incremental Page Display Pattern for User Controls [^] by Acoustic. He built a solution for real asynchronous loading of partial content. His solution was good but had one weakness: he was unable to react to postbacks. Therefore, controls were static. They could only display initial content, and users were unable to interact with the controls. I decided to write a completely new control that could support the following features:

Usage Scenarios

Example scenarios where you could use the PartialUpdatePanel instead of the AJAX UpdatePanel might be

Basic Concepts

The complete control consists of a server-side control, a client-side script part, and an HttpHandler. The rendering scenario of an ASCX control is described in the following image:

  1. The ASPX Page contains a PartialUpdatePanel which has its UserControlPath property set to the ASCX control.

    <iucon:PartialUpdatePanel runat="server" ID="Panel1"
    
                 UserControlPath="~/PostBackSample.ascx">
        <ErrorTemplate>
            Unable to refresh content
        </ErrorTemplate>
    
        <LoadingTemplate>
            <div style="margin-left: 84px; margin-top: 10px;">
    
              <asp:Image ID="Image1" runat="server"
                         ImageUrl="~/images/loading.gif" />
    
            </div>
            <div style="text-align: center">
    
                Updating...
            </div>
        </LoadingTemplate>
    </iucon:PartialUpdatePanel>
  2. When the page loads, some JavaScript calls the PartialUpdatePanelHandler. It sends the path to the user control and also other data like the viewstate of the control, via HTTP-POST.

    // create request
    var request = new Sys.Net.WebRequest();
    request.set_url('PartialUpdatePanelLoader.ashx');
    request.set_httpVerb('POST');
    request.set_body(this._createRequestBody(eventTarget, eventArgument));
    request.set_userContext(this);
    request.add_completed(this._loadingComplete);
  3. The user control needs a Page object to be rendered in. This job is done by PanelHostPage.

    // this code is part of PartialUpdatePanelHandler
    if (context.Request.Form["__USERCONTROLPATH"] != null)
    {
        PanelHostPage page = new PanelHostPage(
           context.Request.Form["__USERCONTROLPATH"],
           context.Request.Form["__CONTROLCLIENTID"]);
    
          ((IHttpHandler)page).ProcessRequest(context);
    
        context.Response.Clear();
          context.Response.Write(page.GetHtmlContent());
    }
  4. The user control gets normally rendered by simply adding it to the Controls collection of the Page.

    protected override void CreateChildControls()
    {
        // Load Control
        if (_controlPath != null)
            _mainForm.Controls.Add(LoadControl(ResolveUrl(_controlPath)));
    
        base.CreateChildControls();
    }
  5. The page output is sent back to the HttpHandler.

  6. The contents are transferred to the client, and inserted into the active HTML-document via DOM-operations.

    contentPanel.innerHTML = sender.get_responseData();

That's all.

ViewState

The contents of a PartialUpdatePanel are handled like this were the whole page. So, it has its own viewstate which is stored in a hidden field. The hidden field is transferred to the HttpHandler and loaded by the PanelHostPage. The logic of loading, serializing, and deserializing the viewstate is done in two overridden methods in PanelHostPage.

private string _pageViewState;

protected override object LoadPageStateFromPersistenceMedium()
{
    PartialPageStatePersister persister = 
            PageStatePersister as PartialPageStatePersister;
    persister.PageState = _pageViewState;
    persister.Load();

    return new Pair(persister.ControlState, persister.ViewState);
}

protected override void SavePageStateToPersistenceMedium(object state)
{
    PartialPageStatePersister pageStatePersister = 
            this.PageStatePersister as PartialPageStatePersister;
    if (state is Pair)
    {
        Pair pair = (Pair)state;
        pageStatePersister.ControlState = pair.First;
        pageStatePersister.ViewState = pair.Second;
    }
    else
    {
        pageStatePersister.ViewState = state;
    }
    pageStatePersister.Save();

    _pageViewState = HttpUtility.UrlEncode(pageStatePersister.PageState);
}

The custom PageStatePersister PartialPageStatePersister uses a LosFormatter to load and store the ViewState and ControlState correctly.

The contents of _pageViewState are transferred back to the client again as a hidden input field.

Event Handling

In ASP.NET, event handling is quite simple. When a user clicks on a button, for example, the ClientID of this button is passed back to the page in the __EVENTTARGET field. This behaviour could be easily reproduced in our scenario. All we have to do is add OnClientClick calls for every button, call from there a method that loads the partial content, and add the event source to the __EVENTTARGET field that is passed to our HttpHandler. We have nothing more to do, the rest is up to the ASP.NET event pipeline.

Using the Control

Before using the control, you have to register the HttpHandler in your web.config:

<httpHandlers>
  <add verb="*" path="*.ashx" validate="false"

       type="iucon.web.Controls.PartialUpdatePanelHandler"/>
</httpHandlers>

Also add a value to the appSettings. Change the value to your individual one!

 <appSettings>
    <add key="PartialUpdatePanel.EncryptionKey" value="k39#9sn1"/>        
 </appSettings>

Then, simply add a PartialUpdatePanel to your page and set the UserControlPath property. Add some controls to the LoadingTemplate and ErrorTemplate. The contents of the LoadingTemplate become visible when update operations are in progress. The contents of the ErrorTemplate are shown if an error occurs during the update (e.g. server timeout). If you set AutoRefreshInterval to a value greater then 0, the panel refreshes every n milliseconds automatically.

There is also a mechanism to communicate with the control via JavaScript or server-side code. Parameters is a collection that takes key-value-pairs. They are passed to the control via HTTP-POST when it is rendered. The following sample shows how to provide some parameters in the ASPX-page, set values via JavaScript, and read them in your ASCX control with the help of the class ParameterCollection.

<%-- PartialUpdatePanel with named parameters --%>
<iucon:PartialUpdatePanel runat="server" ID="PartialUpdatePanel4"

                          UserControlPath="~/ParameterSample.ascx">
    <Parameters>
        <iucon:Parameter Name="MyParameter" Value="Hello world" />

        <iucon:Parameter Name="Counter" Value="0" />

    </Parameters>
    <ErrorTemplate>

        Unable to refresh content
    </ErrorTemplate>

</iucon:PartialUpdatePanel>
<%-- Change the value of the parameter "Counter" and refresh the panel --%>

<script type="text/javascript">
    var counter = 0;

    function updateParameterSample()
    {
        $find("PartialUpdatePanel4").get_Parameters()["Counter"] = ++counter;
        $find("PartialUpdatePanel4").refresh();
    }


</script>

<input type="button" onclick="updateParameterSample(); return false;"

       value="Click to update panel with counter" />

The code-behind of the ASCX reads the parameter values from the ParameterCollection:

public partial class ParameterSample : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        iucon.web.Controls.ParameterCollection parameters =
                  new iucon.web.Controls.ParameterCollection.Instance;

        Label1.Text = "Called " + parameters["Counter"] + " times";
    }
}
You can also change values of your parameters. They will be transfered back and become accessible via JavaScript.

The property InitialRenderBehaviour controls if the control should be rendered by the server during the normal page rendering (InitialRenderBehaviour.Serverside). If this property is set to InitialRenderBehaviour.Clientside, the client sends a request to the server to render the control when the page is already transferred to the browser. This is useful to the user if a part of the page needs longer time to render, but the user should be able to see other parts already. He does not need to wait for the whole page, but can already play with some parts while others are still loading. InitialRenderBehaviour.None causes the control not to render until it is requested via the JScript call $find("PartialUpdatePanel4").refresh(); as shown in one of the above samples. In this case, the <InitialTemplate> contents are shown until a refresh-call occurs.

<iucon:PartialUpdatePanel runat="server" ID="PartialUpdatePanel1"
       UserControlPath="~/ExternalRefreshSample.ascx"
    InitialRenderBehaviour="None">
    <ErrorTemplate>

        Unable to refresh content
    </ErrorTemplate>
    <LoadingTemplate>
        Updating...
    </LoadingTemplate>
    <InitialTemplate>
        Nothing useful here until refresh() gets called
    </InitialTemplate>

</iucon:PartialUpdatePanel>

If you want to prevent flickering with LoadingTemplate and ContentTemplate, you can use the property DisplayLoadingAfter to set a timespan in milliseconds. The loading template won't be shown before this time expires. This is useful if your PartialUpdatePanel refreshes very quickly.

By using the property RenderAfterPanel you can load contents in a sequential order. If your site uses e.g. 10 PartialUpdatePanels with the InitialRenderBehaviour set to Clientside you will fire 10 requests to the Web server at the same time. This can cause a lot of load for the server. RenderAfterPanel means that the current PartialUpdatePanel will not be refreshed after another one was loaded. So the contents are loaded step by step and the load for the server gets reduced.

You can dynamically add and run JavaScript code from your UserControls. The methods ScriptManager.RegisterStartupScript and ScriptManager.RegisterClientScriptBlock are supported as long as you set addScriptTags to true. The following code shows how to show an alert box when the user clicks on a button in a UserControl hosted in the PartialUpdatePanel.

protected void Button1_Click(object sender, EventArgs e)
{
    string script = string.Format("alert('{0}');", TextBox1.Text);

    ScriptManager.RegisterStartupScript(this, GetType(), "alert", script, true);
}

The internal transport and execution of the JavaScript code is a bit tricky. You cannot simply add a <script> tag in your HTML code. Then, when the HTML code updates the DOM-tree of your document, <script> nodes won't be executed. Internally, the PartialUpdatePanel transports all JavaScript snippets in a hidden div. The div is created by the ScriptRenderer class. The PartialUpdatePanel JavaScript code that updates the document with the newly rendered contents reads the div, uses Sys._ScriptLoader.getInstance() to execute the transported JavaScript, and at last, removes the div from the document via DOM operations.

Properties

EncryptUserControlPath encrypts the path to your UserControl using DES algorithm and the value defined in your web.config.
This property is set to true by default.
Attention: If you set EncryptUserControlPath, you cannot change the UserControlPath via JavaScript.
UserControlPath Virtual path to your UserControl
AutoRefreshInterval Forces the Panel to refresh every n milliseconds
DisplayLoadingAfter Render the current UserControl after another successfully loaded
Parameters Described above in this article ;-)
InitialRenderBehaviour Sets the initial rendermode to Serverside, Clientside or None

AJAX Control Toolkit Support

It was a really hard job to get some controls of the AJAX Control Toolkit working with the PartialUpdatePanel. The main problem was that the controls are instantiating themself in the client during runtime by calling $create() in Sys.Application.add_init

Sys.Application.add_init(function() {
    $create(AjaxControlToolkit.AutoCompleteBehavior, {...}, null, null, $get(
        "PartialUpdatePanel7_myTextBox"));
);

Now when a partial post back is finished, the same code runs a second time and the function Sys.Application.addComponent which gets called by $create$ fails because the component was already instantiated.

To solve this problem, I had to make quite a dirty hack. Before the client scripts in the partial update response are executed, I change the function reference of Sys.Application.addComponent to a local one which checks if the component was already instantiated.

_addComponent : function(component) {    
    var id = component.get_id();
    if (typeof(Sys.Application._components[id]) === 'undefined')
        Sys.Application._components[id] = component;
}

This prevents addComponent from failing and throwing an exception. When all scripts ran successfully, the original function pointer is restored.

One Last Word

If you use this control, I would be happy if you send me the URL of your project so I can see the control in action. And... please don't forget to vote for this article.

History & Updates

14th Nov, 2008

Version 1.6

Special thanks to grown from CodePlex for his excellent work on the PartialUpdatePanel!
  • Added encryption support for UserControl path
  • Added support for custom ScriptManager types (includes ToolkitScriptManager)
  • Added support for ToolkitScriptManager.CombineScriptsHandlerUrl
  • Change UserControlPath using JavaScript during runtime
  • Manipulate Parameters serverside during roundtrip
  • Fixed issue using validators and rendering in Clientside mode
  • Fixed a bug with recreating components
9th July, 2008

Version 1.5.2

  • Fixed a bug with supporting the state of RadioButtons
  • Added support for globalization
  • Showing up extended exception information
10th June, 2008

Version 1.5

  • Added support for some Controls from the ASP.NET AJAX Control Toolkit
  • Added support for ScriptManager.RegisterDataItem
  • Added support for ScriptManager.RegisterClientScriptInclude
  • New example called ToolkitSample shows some Toolkit controls inside the PartialUpdatePanel
20th May, 2008

Version 1.4

  • ControlState is now transferred correctly between postbacks using a custom PageStatePersister
  • New property DisplayLoadingAfter
  • New property RenderAfterPanel
  • Minor bug fixes
29th Mar, 2008

Version 1.3

  • Added support for ScriptManager.RegisterStartupScript to run JScript code after partial postbacks
  • Parameters are no more transported via HTTP-GET but via HTTP-POST
  • Output bug fix: the <form> tag was rendered more than once when using controls with the InitialRenderMode server-side
28th Feb, 2008

Version 1.2.1

  • Minor bug fix: Viewstate of initially server-side rendered controls were not handled correctly on normal postbacks
27th Feb, 2008

Version 1.2

  • Added the property InitialRenderBehaviour to PartialUpdatePanel
  • Added IRequiresSessionState to PartialUpdatePanelHandler (thanks to aliascodeproject)
  • UrlEncode-d the viewstate in PanelHostPage (thanks to Acoustic)
20th Feb, 2008 Initial release

The project is hosted on CodePlex [^]. The updates there are uploaded in smaller intervals. So if you are interested in this project, you should visit this site regularly.

Known Problems

The ModalPopupExtender runs fine only in FireFox. IE has some problems I have not solved yet. So if you want to show a modal popup from within a PartialUpdatePanel, create the ModalPopupExtender in the parent page. To show the dialog, call ScriptManager.RegisterStartupScript in the code behind of your PartialUpdatePanel UserControl.
Example:

<script type="text/javascript">
function showModalPopupViaClient() {            
    var modalPopupBehavior = $find('programmaticModalPopupBehavior');
    modalPopupBehavior.show();
}
        
function hideModalPopupViaClient() {            
    var modalPopupBehavior = $find('programmaticModalPopupBehavior');
    modalPopupBehavior.hide();
}
</script>
    
<asp:Button runat="server" ID="hiddenTargetControlForModalPopup" style="display:none"/>

<ajaxToolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup"
    BehaviorID="programmaticModalPopupBehavior"
    TargetControlID="hiddenTargetControlForModalPopup"
    PopupControlID="programmaticPopup" 
    BackgroundCssClass="modalBackground"

    DropShadow="True"
    PopupDragHandleControlID="programmaticPopupDragHandle"
    RepositionMode="RepositionOnWindowScroll" >
</ajaxToolkit:ModalPopupExtender>
<asp:Panel runat="server" CssClass="modalPopup" ID="programmaticPopup"

    style="display:none;width:350px;padding:10px">
<asp:Panel runat="Server" ID="programmaticPopupDragHandle"
    Style="cursor: move;background-color:#DDDDDD;border:solid 1px Gray;
    color:Black;text-align:center;">
    ModalPopup shown and hidden in code


</asp:Panel>

<iucon:PartialUpdatePanel runat="server" ID="PartialUpdatePanel4"
    UserControlPath="~/ToolkitSample.ascx" />

You can now use this sample to see how to use ModalPopup with an invisible TargetControl.
The ModalPopupExtender
this popup is attached to has a hidden target control. The popup is hidden 
<asp:LinkButton runat="server" ID="hideModalPopupViaServer" Text="on the server side
    in code behind" OnClick="hideModalPopupViaServer_Click" /> and 

<a id="hideModalPopupViaClientButton" href="#">on the client in script</a>.

<br />
</asp:Panel>

The code behind in your PartialUpdatePanel UserControl will look like

public partial class ToolkitSample : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, GetType(), "showPopup",
            "showModalPopupViaClient()", true);
    }
}

This will execute showPopup after a partial PostBack and the modal popup gets shown.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralInteresting, but one Question: on User Control Event
sriprabu
9:47 3 Feb '10  
If the UserControl Inside raises an Event that the hosting page needs to capture? how do you recommend to handle it?
GeneralIsPostBack and Page_Load
claudiocas
5:45 15 Jan '10  
Dear Stefan
you did a really great job!
I'm in trouble with my controls because I often check in Page_load the IsPostBack property to initialize the control
 
if(!IsPostBack)
{
//Init Code....
}

if I use the PartialRender when the PageLoad of ascx is call, the IsPostBack is set to true and so all the initialization are skipped.
How I can check if is the "initialization call" of the Partial Update Panel?

Thanks a lot
Claudio Cas
GeneralRe: IsPostBack and Page_Load
claudiocas
4:48 20 Jan '10  
Stefan send me this walkaround:
My workaround was to declare a ViewState-Property in the UserControl loaded by PartialUpdatePanel and set it to true at the first PreRender. So next time the control is loaded by a PostBack, the Property is true as an indicator, the control was loaded the second time.
Example:


public class PostBackUserControl : UserControl
{
protected new bool IsPostBack
{
get { return (bool)(ViewState["IsPostBack"] ?? false); }
set { ViewState["IsPostBack"] = true; }
}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

IsPostBack = true;
}
}

With this way you can check the now new declared property IsPostBack in your OnLoad code. It simulates the behavior of ASP.NET IsPostBack.
I hope this helps,
GeneralPass javascript parameter to parameter collection
jackandjo
4:56 27 Oct '09  
Hi,

I have a javascript function which holds the id of a record that I want to load into the user control, how can I pass the id to the parameter collection?
At the moment I am just storing the value in a label control.

function attachWindowToLink(oLink) {

document.getElementById("editpanel_lblusername").firstChild.nodeValue = oLink.id.toString().replace("grid_link_", "");
}

Would be grateful for any help.

Great control by the way Smile

Jack
GeneralRe: Pass javascript parameter to parameter collection
jackandjo
5:53 27 Oct '09  
I have tried

function attachWindowToLink(oLink) {
$find('editpanel_PartialUpdatePanel4').get_Parameters()["username"] = oLink.id.toString().replace("grid_link_", "");

but it does not seem so work.
GeneralRe: Pass javascript parameter to parameter collection
jackandjo
6:03 27 Oct '09  
Sorted

$find('editpanel_PartialUpdatePanel4').get_Parameters()["username"] = oLink.id.toString().replace("grid_link_", "");
$find('editpanel_PartialUpdatePanel4').refresh();
GeneralAccessing parameters in VB
NeillR
13:24 12 Oct '09  
Stefan,

This seems to be a great dll, but i'm having trouble passing the parameters to my control. Call me a noob, but i code in VB (i'm too old to learn new tricks) and i can't figure out how to access the parameters collection in vb.

My code looks like this:


Dim params As iucon.web.Controls.ParameterCollection = iucon.web.Controls.ParameterCollection.Instance

CatID = params("CatID")



Basically i'm passing the categoryID from a dropdownlist to grab those items from the db. If anyone can help, i'd be most grateful.

Cheers

modified on Monday, October 12, 2009 11:53 PM

GeneralIt doesn't like ScriptMode on ScriptManager?
dsdfdaadfbscvvc
7:36 2 Oct '09  
Great control! However, if I set ScriptMode to "Release" on the ScriptManager I get:
Invalid cast from 'System.String' to 'System.Web.UI.ScriptMode'

Any thoughts on why that is? And how to get around it without removing the ScriptMode property? I don't really want to run all my production code in debug mode after all.

Thanks
GeneralGet instance of control
Simón de Lizarza
7:56 24 Sep '09  
Hi,

How do you get the instance of the UserControl loaded in the update panel? I need this because I have to access some procedures in the usercontrol after it is loaded.

Thanks.
GeneralRe: Get instance of control
S. Kolic
2:08 5 Oct '09  
I want to do this too. I have a control container which has the partial update panel. The control container has an edit button, when I press this button I want to execute the Edit() method in my loaded control which implements an interface.

So i want something like:

Dim lLoadedControl As IMyControlInterface = Me.PartialUpdatePanel.GetLoadedControl()
lLoadedControl.Edit()


Actually, what I want to do is pass the control object and put it in the Partial Update Panel instead of telling the location of the control to load. So if I do this in my code, is it possible to refacture your component:
Dim lMyControl As IMyControlInterface = LoadControl("~/Control/MyControl.ascx")
' VERY Important, because this way, the control will know its parent container and can call the special functions like OnEdited etc... Or is it better to use another way?
lMyControl.InitContainer(Me)

Me.PartialUpdatePanel.UserControl = lMyControl


Is it possible to refacture the code to support this?
GeneralResponse.Redirect not working
Jaswinder Singh
23:44 2 Sep '09  
sir ,

there not work Response.Redirect used in control pages , please resolved my problem .

Response.Redirect(UrlText);

jassy

General/PartialUpdatePanelLoader.ashx
UrKo
22:44 25 Aug '09  
Where is that page in your demo?
QuestionMultiple controls with the same ID 'ctl00' were found. FindControl requires that controls have unique IDs. [modified]
MaksAnt
5:35 7 Aug '09  
TreeView is not work into PartialUpdatePanel.

modified on Wednesday, August 12, 2009 5:14 AM

QuestionPartialUpdatePanel + WebParts
MaksAnt
6:20 5 Aug '09  
How PartialUpdatePanel should be used within web parts?
QuestionDynamically loading the user controls
Member 2518959
7:55 9 Jul '09  
I have different tabs on my page. The data displayed for one of the tabs requires to be refreshed after every 15 mins.so I created a PartialUpdatePanel to load a user control for this. clicking on other tabs loads other user controls. However when I load other tabs, I try to clear the PartialUpdatePanel, but there appears a javascript error message. null is null not an object.

private void LoadUserControls(string stabType)
{
try
{
iucon.web.Controls.PartialUpdatePanel oP = new iucon.web.Controls.PartialUpdatePanel();
if (stabType.Equals(Constants.HEADLINETYPE_FEATURED))
{

oP.UserControlPath = "UserControls/FeatureHeadline.ascx";
oP.AutoRefreshInterval = 60000;
oP.InitialRenderBehaviour = iucon.web.Controls.InitialRenderBehaviour.Clientside;
pnlFeatureUpdate.Controls.Add(oP);


}
else
{
TopHeadlines1.Visible = true;
pnlFeatureUpdate.Controls.Clear();

}
}
catch (Exception ex)
{
}
}

Any suggestion?????
GeneralAJAX ModalPopUPExtender
omsatchitanand
19:13 19 Mar '09  
Hi,
I am using ModalPopupExtender to show a large image from the samll image link.
Actually I want to go forward and backward in the same window.
I don't know how to goo forward? Can somebody help me to do this?

Thanks in advance.
GeneralRe: AJAX ModalPopUPExtender
Dewey
22:11 31 Mar '09  
Get the latest code on Codeplex, the code here is old.
Questionusing fileupload
Member 4668801
5:57 8 Jan '09  
Hi, great article!
I am using a FileUpload control inside my user control but can't get the file since the control requires a full page postback.
I've tried to register the button that would cause the postback against the scriptmanager inside the page_load() of the user control but can't get the thing to work!

protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.GetCurrent(Page).RegisterPostBackControl(SaveButton);
...
}

Any ideas on how to get this working?

Thks
QuestionMultiple PartialUpdatePanels on a page not loaded asynchronously [modified]
ajakblackgoat
17:43 19 Nov '08  
Hi stefan, firstly, thanks for your wonderful component!

I tried your component and it works just great. The problem is, I found out that when a page has several of your panels, they got loaded synchronously (i.e: one after another) when :

1. there is Session_Start event declared in global.asax in the project (even the event has no code inside it).
2. we save data in Session object (E.g: Session("Name") = some value) prior to loading the panel content.

I hope you will fix it soon as it's an awesome components not to use it.

Thanks.

modified on Thursday, November 20, 2008 8:58 PM

QuestionAutoRefresh
stixoffire
22:09 11 Nov '08  
When this control autorefreshes - is there a command such as OnRefresh - so that when the panel begins a refresh request - I can programatically change some data going to the server or tell the server to send different data for the refresh.
For example in a product advert - I want a different product to be displayed every n time.
AnswerRe: AutoRefresh
iucon
22:32 11 Nov '08  
Hi,

currently there is no JavaScript event which gets raised before an update.
I will add your request to my ToDo and make a new release this week.

So please watch this forum, I will post when the release is ready for download.

Regards,
Stefan
AnswerRe: AutoRefresh
iucon
1:17 14 Nov '08  
Hi stixoffire,

the new release is ready for download on Codeplex.
Now the control provides a new JScript event called refreshStarting.
It gets raised whenever the control is about to refresh itself.

So please use this event to modify some data before refreshing.

Regards,
Stefan
QuestionHow to redirect to another page?
Member 1523434
3:27 3 Nov '08  
Hello,

I am trying to redirect to another page from inside my control (when clicking on a linkbutton for example).
If I use Response.Redirect, I just get some text: 21|pageRedirect||http://www.google.com|
If I use Server.Transfer, I just see "Updating..." indefinitely.

Thanks in advance,
Cosmin.
AnswerRe: How to redirect to another page?
iucon
22:41 11 Nov '08  
Hi Cosmin,

Response.Redirect does not work, because it send an HTTP-Header with the command to redirect to your browser.
These headers are not used when making an AJAX request.
So your way is to use a javascript redirect.

Put the following snippet inside your LinkButton_Click method:

string script = "window.location.href = '{0}';";
script = string.Format(script, VirtualPathUtility.ToAbsolute("~/RedirectToThisPage.aspx"));

ScriptManager.RegisterStartupScript(this, GetType(), "redirect", script, true);

I hope this helps,
Stefan
Questionget control from parent page
silvia_4u
3:03 13 Oct '08  
How can I get a control from the page that contains the PartialUpdatePanel. I tried this.Page.FindControl("xx") , this.Parent.FindControl("xx") and it's not working. Any solution?


Last Updated 14 Nov 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010