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

Window skin broken (large code blocks)

2 Answers 40 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dan Miller
Top achievements
Rank 1
Dan Miller asked on 15 Jul 2010, 06:42 PM
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:
<%@ 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);
 }
}
*/

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 16 Jul 2010, 09:09 AM
Hello Daniel,

Make sure that you have set EnableAjaxSkinRendering to true whenever you show the RadWindow from the server.


Regards,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Miller
Top achievements
Rank 1
answered on 16 Jul 2010, 05:54 PM
Well that was an incredibly simple answer. Worked like a charm! Thanks a lot :)
Tags
Window
Asked by
Dan Miller
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Dan Miller
Top achievements
Rank 1
Share this question
or