This is a migrated thread and some comments may be shown as answers.

IPostBackEventHandler with UserControl not showing LoadingPanel

3 Answers 64 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Joshua Grippo
Top achievements
Rank 1
Joshua Grippo asked on 22 Jul 2011, 06:33 PM
I am trying to develop a framework that is extensible through user controls. In order to do this, I need to be able to use a UserControl as the target of an ajax request and I need to be able to pass an argument with it. I have done this through the implementation of IPostBackEventHandler. However when it posts back, depending on the browser, it doesn't refresh the UI(IE) or it never shows the loading panel. the "btnUpdateLabel", button always works and is there as a check. the "btnClientScript" uses JS to do the ajaxrequestwithtarget which does not show the loading panel.

below are the contents of 4 files to replicate this.

aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserControlPage.aspx.cs"
    Inherits="UserControlPage" %>
 
<%@ Register src="UserControls/PostBackeEventHandlerTest.ascx" tagname="PostBackeEventHandlerTest" tagprefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="mgrScript" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="mgrAjax" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="pnlLoading" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <uc2:PostBackeEventHandlerTest ID="PostBackeEventHandlerTest1" runat="server" />
    </form>
</body>
</html>

aspx.cs
using System;
using System.Web.UI;
using Telerik.Web.UI;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Collections;
 
public partial class UserControlPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //increase the request queue so we can have multiple requests loading.
        RadAjaxManager.GetCurrent(this.Page).RequestQueueSize = 50;
    }   
}

ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PostBackeEventHandlerTest.ascx.cs" Inherits="UserControls_PostBackeEventHandlerTest" %>
<telerik:RadAjaxLoadingPanel ID="pnlLoading" Runat="server"
    Skin="Default">
</telerik:RadAjaxLoadingPanel>
<asp:Label ID="lblButtonTarget" runat="server" Text="Updated From Button"></asp:Label>
<br />
<asp:Button ID="btnUpdateLabel" runat="server" Text="Update Time Regular" />
<br />
<br />
<asp:Button ID="btnClientScript" runat="server" Text="Update Time ClientScript" />
<br />
<br />
<asp:Label ID="lblPostbackevent" runat="server" Text="Updated From PostBack"></asp:Label>

ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class UserControls_PostBackeEventHandlerTest : System.Web.UI.UserControl,IPostBackEventHandler
{
    protected void Page_Load(object sender, EventArgs e)
    {      
        var mgr = Telerik.Web.UI.RadAjaxManager.GetCurrent(this.Page);
        mgr.AjaxSettings.AddAjaxSetting(this.btnUpdateLabel, this.lblButtonTarget, this.pnlLoading);
        mgr.AjaxSettings.AddAjaxSetting(mgr, this.lblPostbackevent, this.pnlLoading);
 
        this.btnUpdateLabel.Click += new EventHandler(btnUpdateLabel_Click);
        this.btnClientScript.OnClientClick = "var mgr = $find('" + mgr.ClientID + "');mgr.ajaxRequestWithTarget('" + this.UniqueID + "', 'I need to pass a param');";
    }
 
    void btnUpdateLabel_Click(object sender, EventArgs e)
    {
        this.lblButtonTarget.Text = DateTime.Now.ToString();
    }
 
    public void RaisePostBackEvent(string eventArgument)
    {
        this.lblPostbackevent.Text = DateTime.Now.ToString();
    }
}

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 25 Jul 2011, 02:46 PM
Hello Joshua Grippo,

Please review the answer provided in the support ticket you have opened for the same issue. Test the provided approach and let me know if further assiatance is needed.

Kind regards,
Maria Ilieva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Joshua Grippo
Top achievements
Rank 1
answered on 07 Aug 2011, 05:50 PM
The response was that it is not possible.
0
Sebastian
Telerik team
answered on 08 Aug 2011, 09:51 AM
Hi Joshua,

Here is the reply my colleague Maria provided in the support ticket connected to this subject:

After further testing on our side we came to a final conclusion that the required functionality could not be achieved with RadAjaxManager. You could not postback directly through the UserControl if it is not added in a container. As your requirements are to create all the logic independently in the UserControl I would suggest you to use RadAjaxPanel to wrap the whole content of the UserControl instead of RadAjaxManager. I hope this covers your requirements and will allow you to create the needed module.

Excuse us for any inconvenience this limitation may lead.

Kind regards,
Sebastian
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Ajax
Asked by
Joshua Grippo
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Joshua Grippo
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or