I have a radwindow on a Masterpage that I reference from the Web User Control pages of Web Forms that use the Masterpage (Masterpage -> WebForm.aspx -> WebUserControl.ascx + Codebehind.cs). On the page I have a context menu that is triggered by right-clicking on a div. One of the options of the context menu sets the navigateurl of the radwindow then makes it visible. The first time I make the radwindow appear everything is perfect (see attached: window works.png), however after closing the radwindow and doing an ajax postback on the page if I open the radwindow again, its look is totally broken (see attached: broken window.png). I have put in some code blocks that will hopefully help a bit. If there are any questions please ask!
This is the web control:
web control code behind, contextmenu item click function.
This is the web control:
<%@ Control Language=
"C#"
AutoEventWireup=
"true"
CodeFile=
"ContentMenu.ascx.cs"
Inherits=
"CMSControls_ContentMenu"
%>
<%@ Register Assembly=
"Telerik.Web.UI"
Namespace=
"Telerik.Web.UI"
TagPrefix=
"telerik"
%>
<telerik:RadAjaxManagerProxy ID=
"RadAjaxManagerProxy"
runat=
"server"
>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID=
"RadContextMenuMenu"
>
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID=
"RadContextMenuMenu"
/>
<telerik:AjaxUpdatedControl ControlID=
"RadWindowMaster"
/>
<telerik:AjaxUpdatedControl ControlID=
"LabelDebug"
/>
<telerik:AjaxUpdatedControl ControlID=
"divMenu"
LoadingPanelID=
"radAjaxLoadingPanel"
/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<asp:PlaceHolder ID=
"PlaceHolderAdmin"
runat=
"server"
/>
<div id=
"divMenu"
>
<asp:Literal ID=
"LiteralEmptyMenu"
runat=
"server"
/>
<asp:PlaceHolder ID=
"PlaceHolderRadMenuCMS"
runat=
"server"
/>
</div>
<asp:Label ID=
"LabelDebug"
runat=
"server"
Text=
""
/>
<telerik:RadCodeBlock ID=
"RadCodeBlock1"
runat=
"server"
>
<script type=
"text/javascript"
>
<asp:Literal ID=
"LiteralOnClientClose"
runat=
"server"
/>
</script>
</telerik:RadCodeBlock>
web control code behind, contextmenu item click function.
protected
void
RadContextMenuMenu_ItemClick(
object
sender, Telerik.Web.UI.RadMenuEventArgs e)
{
if
(IsAdmin)
{
LabelDebug.Text +=
"RadContextMenuCMS_ItemClick "
+ e.Item.Text +
"<br>"
;
MasterPage myMaster = Page.Master;
RadContextMenu RadContextMenuMenu = (RadContextMenu)Shuware.ShuwareCommon.Web.FindControlByID(PlaceHolderAdmin.Controls,
"RadContextMenuMenu"
);
RadWindow RadWindowMaster = (RadWindow)myMaster.FindControl(
"RadWindowMaster"
);
//Create a new RadWindow object and assign it the ID of the RadWindow hidden on the page
switch
(e.Item.Text)
{
case
"Edit"
:
RadWindowMaster.NavigateUrl =
"~/contentmenueditor.aspx?id="
+ Server.UrlEncode(MenuID.ToString());
RadWindowMaster.OnClientClose =
"OnClientclose"
+
"_"
+
this
.ID;
RadWindowMaster.AutoSize =
false
;
RadWindowMaster.Visible =
true
;
RadWindowMaster.Height = Unit.Pixel(555);
RadWindowMaster.Width = Unit.Pixel(485);
RadContextMenuMenu.Items[1].Visible =
true
;
RadContextMenuMenu.Items[2].Visible =
true
;
break
;
case
"Save"
:
RadContextMenuMenu.Items[1].Visible =
false
;
RadContextMenuMenu.Items[2].Visible =
false
;
RadWindowMaster.Visible =
false
;
Response.Redirect(Shuware.ShuwareCommon.Web.GetCurrentURL());
//redirect back to the same page
break
;
case
"Cancel"
:
RadContextMenuMenu.Items[1].Visible =
false
;
RadContextMenuMenu.Items[2].Visible =
false
;
RadWindowMaster.Visible =
false
;
break
;
case
"Admin"
:
RadContextMenuMenu.Items[1].Visible =
false
;
RadContextMenuMenu.Items[2].Visible =
false
;
RadWindowMaster.OnClientClose =
"OnClientclose"
+
"_"
+
this
.ID;
RadWindowMaster.NavigateUrl =
"~/admin.aspx"
;
RadWindowMaster.Visible =
true
;
//show the admin window
break
;
default
:
RadContextMenuMenu.Items[1].Visible =
false
;
RadContextMenuMenu.Items[2].Visible =
false
;
RadWindowMaster.Visible =
false
;
break
;
}
}
}
This sets the onclientclose function for the radwindow.
string
strScript =
"function OnClientclose"
+
"_"
+
this
.ID +
"(sender, eventArgs)\n{\n var arg = eventArgs.get_argument();\nif(arg) {\n__doPostBack('ctl00$"
+ RadContextMenuMenu.ClientID.Replace(
"_"
,
"$"
) +
"', arg);\n}\n}"
;
LiteralOnClientClose.Text += strScript;
/*This becomes the below code at runtime:
function OnClientclose_ContentMenu1(sender, eventArgs)
{
var arg = eventArgs.get_argument();
if(arg) {
__doPostBack('ctl00$ctl00$ContentPlaceHolder1$ContentMenu1$RadContextMenuMenu', arg);
}
}
*/