From DockPositionChanged event, how to invoke a RadNotification control?

1 Answer 47 Views
Ajax AjaxPanel Dock Notification
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
Hugo Augusto asked on 12 Jan 2023, 10:05 PM | edited on 12 Jan 2023, 10:06 PM

I allow the user to create in runtime, zones (my sections) and docks.

<asp:Repeater ID="repSections" runat="server" OnItemDataBound="repSections_ItemDataBound">
        <ItemTemplate>
            <asp:Panel ID="panelSection" runat="server" CssClass="container">
		
			A RadDockZone(section) and it's RadDocks are injected here in runtime...

		</asp:Panel>
        </ItemTemplate>        
    </asp:Repeater>

This repeater is populated from database and zones and it's docks injected in runtime, assigning the DockPositionChanged event to each of the created docks. Since I also inject in runtime, controls before and after each zone to manage it (Add, configure, move up/down) and I want them to postback using ajax, I'm configuring the ajax behavior in the ItemDataBound event of the Repeater:

protected void repSections_ItemDataBound(object sender, RepeaterItemEventArgs e)

{

LinkButton linkbtAddNormalSection = e.Item.FindControl("linkbtAddNormalSection") as LinkButton;
linkbtAddNormalSection.CommandArgument = section.Id.ToString();
AjaxSetting ajaxSetting_linkbtAddNormalSection = new AjaxSetting();
ajaxSetting_linkbtAddNormalSection.AjaxControlID = linkbtAddNormalSection.UniqueID;
ajaxSetting_linkbtAddNormalSection.EventName = "Click";
ajaxSetting_linkbtAddNormalSection.UpdatedControls.AddRange(new AjaxUpdatedControlsCollection()
{
 new AjaxUpdatedControl(repSections.UniqueID,""),
                            new AjaxUpdatedControl(panelNosections.UniqueID,""),
                            new AjaxUpdatedControl(radNotification.UniqueID, "")
});
ajaxManagerProxy.AjaxSettings.Add(ajaxSetting_linkbtAddNormalSection);

...

}

Because of this, RadAjax places a RadAjaxPanel that includes all the created zones inside of the repeater causing the DockPositionChanged event to function in ajax mode. That's fine, and works great since avoids a regular postback each time a dock changes position. 

The issue is that I need to show a RadNotification that is outside the repeater and consequently, outside that RadAjaxPanel and I can't show it from the  DockPositionChanged event. 

Any suggestion to overcome this?

 

Thank you!

Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
commented on 13 Jan 2023, 12:29 AM | edited

Ignore the previous issue. The RadNotification is shown. The issue is that I have a usercontrol inside the ContentTemplate and it's properties set in runtime are not rendering. Tried placing the usercontrol directly inside the <ContentTemplate> tag and injecting it in runtime using LoadControl and setting the UC properties but the issue persists in both cases. The UC html appears but with no content from the properties. It's like the server controls of the UC inside ContentTemplate are not getting updated with the values passed in runtime. Any ideas?

 

1 Answer, 1 is accepted

Sort by
0
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 13 Jan 2023, 02:39 AM

Found the solution. You should add this to documentation since it's not mentioned anywhere and when using AJAX it's required.

So, the solution was to add LoadContentOn="EveryShow" to my RadNotification control. This seems to forces RadNotification to update it's contents on a postback, and when using Ajax it works great. I can now have a user control inside the ContentTemplate to show the UI of notifications according to passed parameters in runtime.

<telerik:RadNotification ID="radNotification" runat="server" RenderMode="Lightweight" AutoCloseDelay="4000" KeepOnMouseOver="true" Position="TopCenter" Skin="" 
        EnableEmbeddedSkins="false" Width="80%" ShowCloseButton="false" VisibleTitlebar="false" Animation="Fade" AnimationDuration="300" VisibleOnPageLoad="false" 
        CssClass="ecm-notification" LoadContentOn="EveryShow">    
        <ContentTemplate>            
            <eCM:Notification id="floatingNotification" runat="server"></eCM:Notification>
        </ContentTemplate>
    </telerik:RadNotification>

In code behind, in my Dock_DockPositionChanged event, I can now make my notification appear using a simple method:

private void ShowNotification(string title, string message, Notifications.MessageTypeEnum notificationType, bool showFloating)
{
       floatingNotification.Show(title, message, notificationType);
       radNotification.Show();
}

 

Once again, the usage of the parameter LoadContentOn="EveryShow", should be more documented,

Valentin Dragnev
Telerik team
commented on 17 Jan 2023, 01:30 PM

Hello Hugo, 

Glad to see that you found a solution to the problem. 

Just wanted to share this useful article from the docs: Load Content Via Callback.

We will take your feedback and try to improve the documentation to be more detailed and descriptive. 

Kind Regards

Tags
Ajax AjaxPanel Dock Notification
Asked by
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or