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

Radwindow from dock custom command

7 Answers 188 Views
Window
This is a migrated thread and some comments may be shown as answers.
Atiq Ur Rehman
Top achievements
Rank 1
Atiq Ur Rehman asked on 08 Aug 2008, 09:03 AM
Hi I am creating dynamic docks and assiging them a custom command. When the custom command is fired, I want to open a radWindow from there. I am also using RadAjaxPanel on the page. The window should open from server side not from client side.
Here is a bit of code where I am assigning custom command to docks

Dim

editCMD As New DockCommand

editCMD.Name =

"editCMD"

editCMD.Text =

"Edit"

editCMD.CssClass =

"pullEditImage"

editCMD.AutoPostBack =

True

aDock.Commands.Add(editCMD)

AddHandler
aDock.Command, AddressOf dock_Command

here is the handler from where I want to open a radwindow.

Sub dock_Command(ByVal sender As Object, ByVal e As DockCommandEventArgs)

If e.Command.Name = "editCMD" Then

'open window to edit

Dim nw As New RadWindow

nw.ID =

"asdfasdfsd"

nw.NavigateUrl =

"./previews.aspx?show=DDLPropertiesCTL&i=a"

nw.VisibleOnPageLoad = True

Dim rwm As RadWindowManager = CType(Page.FindControl("RadWindowManager1"), RadWindowManager)

rwm.Windows.Add(nw)

End If

End Sub

I am trying to do it this way but this is not working. Please can someone help me out here.

Thanks

7 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 08 Aug 2008, 10:54 AM
Hello Atiq,

The code that you sent seems OK so the problem must be in the way you ajaxify the controls. Can you please provide more information on your setup? It will be best to open a support ticket and to send us a small sample project where this problem can be reproduced - we will check it right away.



Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Atiq Ur Rehman
Top achievements
Rank 1
answered on 08 Aug 2008, 11:49 AM
Hi,

The problem is I can't send the project. It's in DNN and there are so many things connected to it that you won't be able to run it. I can copy the code from my page though. Ok what I am doing is, I am loading the ascx control in multiview on an aspx page. Most of the javascript is on aspx page, but I have couple of things on ascx control as well, which I don't think make any difference. Here is the code for ascx page;

ascx page
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Questions.ascx.vb" Inherits="Questions" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="radT" %> 
 <style type="text/css">     
   .rdContent     
   {      
        height:100%;  
   }   
   .rddd  
   {   
        width:100%;  
   }    
   .rdTextBox  
   {  
        height:100%;  
   }  
</style>    
      
        <script type="text/javascript">  
         
        function delCustomCommand(dock, args)  
        {  
            args.set_cancel(true);   
            var callbackFn = function(arg)   
            {    
                if(arg)   
                { //if dialog returned true, close the dock    
                dock.set_closed(true);    
                dock.doPostBack('deleteCMD');  
                }    
            }    
        //Call the confirm dialog    
        radconfirm('Are you sure you want to delete this question?', callbackFn, 330, 100);   
        }   
          
        Telerik.Web.UI.RadWindowUtils.Localization =     
        {    
        "Close" : "Close",    
        "Minimize" : "Minimize",    
        "Maximize" : "Maximize",    
        "Reload" : "Reload",    
        "PinOn" : "Pin on",    
        "PinOff" : "Pin off",    
        "Restore" : "Restore",    
        "OK" : "Yes",    
        "Cancel" : "No",    
        "Yes" : "Yes",    
        "No" : "No"      
        };   
 
        </script> 
          
<radT:radformdecorator id="FormDecorator1" runat="server" decoratedcontrols="CheckBoxes, RadioButtons, Buttons" skin="Sunset">  
        </radT:radformdecorator> 
          
        
 
    <table width="100%" id="notAllowed" runat="server">  
    <tr> 
    <td>You don't have permission to view this page. Please contact support.<br /> 
    <input id="Button1" onclick="returnToParent(); return false;" type="button"   
                value="Close" class="button" /></td>  
    </tr> 
    </table> 
    
  <asp:Panel ID="mainPNL" runat="server" Width="100%">  
        <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> 
        <table id="Table1" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">  
        <TR> 
            <TD> 
                <asp:label id="lblmsg" runat="server" Font-Bold="True" ForeColor="#C00000"></asp:label> 
                <asp:Literal id="ltError" runat="server"></asp:Literal></TD>  
        </TR> 
    </TABLE> 
 
    <fieldset><legend>Question</legend> 
   
    <radT:RadSplitter ID="rdSPlitter" runat="server" Width="100%" Height="100%">  
 <radT:RadPane ID="rdPanQuestions" Runat="server" Width="20%">  
   
       <radT:RadTreeView ID="rdQuestions" runat="server" AutoPostBack="True"   
           Skin="Sunset" Font-Size="Small">  
     
           <CollapseAnimation Duration="100" Type="OutQuint" /> 
           <ExpandAnimation Duration="100" /> 
     
        </radT:RadTreeView> 
    
 </radT:RadPane> 
<radT:RadSplitBar ID="rdSplitBar" runat="server" /> 
 
<radT:RadPane ID="rdPanTables" runat="server" Width="80%">  
 
               <radT:raddocklayout runat="server" id="rdLayout" Skin="Sunset">  
            <radT:raddockzone runat="server" id="rdZone" Width="95%">  
            </radT:raddockzone> 
            <div style="display:none">  
                Hidden UpdatePanel, which is used to receive the new dock controls.   
                We will move them with script to the desired initial dock zone.  
                <asp:updatepanel runat="server" id="uPanel">  
                    <triggers> 
             
                    </triggers> 
                </asp:updatepanel> 
            </div> 
        </radT:raddocklayout> 
          
</radT:RadPane> 
</radT:RadSplitter> 
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">  
<tr> 
<td align="left">  
<%--<input id="submit" onclick="returnToParent(); return false;" type="button"   
                value="Close" class="button" />--%> 
      
    <asp:Button ID="ExitBTN" runat="server" CausesValidation="false"   
        CssClass="button" Text="Exit" Width="120px" /> 
      
</td> 
<td align="right">  
 
    &nbsp;<asp:Button ID="previousBTN" runat="server" CausesValidation="False"   
        CssClass="button" Text="Previous" Width="120px" /> 
    &nbsp;&nbsp;  
    <asp:Button ID="nextBTN" runat="server" CssClass="button" Text="Save"   
        Width="120px" /> 
 
</td> 
</tr> 
</table> 
 
    </fieldset> 
  </asp:Panel> 

Here is the code file for this ascx;
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init  
            createDocks()  
        End Sub  
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
                If Not IsPostBack Then  
                    mainPNL.Visible = True 
                    notAllowed.Visible = False 
                    createNodes()  
                End If  
        End Sub  
 
    Sub createNodes()  
            Dim textboxnod As New RadTreeNode("TextBox", "TextBox")  
            textboxnod.Attributes.Add("onclick", "openWin('./previews.aspx?show=textBoxPropertiesCTL','640','520'); return false;")  
            rdQuestions.Nodes.Add(textboxnod)  
            Dim ddlnode As New RadTreeNode("DropDownList", "DropDownList")  
            ddlnode.Attributes.Add("onclick", "openWin('./previews.aspx?show=DDLPropertiesCTL','640','520'); return false;")  
            rdQuestions.Nodes.Add(ddlnode)  
            Dim fltddlNod As New RadTreeNode("FilterDropDownList", "FilterDropDownList")  
            fltddlNod.Attributes.Add("onclick", "openWin('./previews.aspx?show=DDLPropertiesCTL&type=fddl','640','520'); return false;")  
            rdQuestions.Nodes.Add(fltddlNod)  
            Dim rblNod As New RadTreeNode("RadioButtonList", "RadioButtonList")  
            rblNod.Attributes.Add("onclick", "openWin('./previews.aspx?show=DDLPropertiesCTL&type=rbl','640','520'); return false;")  
            rdQuestions.Nodes.Add(rblNod)  
            Dim lblNod As New RadTreeNode("Label", "Label")  
            lblNod.Attributes.Add("onclick", "openWin('./previews.aspx?show=LabelCTL','640','520'); return false;")  
            rdQuestions.Nodes.Add(lblNod)  
            Dim chkNod As New RadTreeNode("Checkbox", "Checkbox")  
            chkNod.Attributes.Add("onclick", "openWin('./previews.aspx?show=CheckboxCTL','640','520'); return false;")  
            rdQuestions.Nodes.Add(chkNod)  
 
        End Sub  
 
   Sub createDocks()  
            Try  
                Dim bcID_int As Integer = 0 
                Dim sID_int As Integer = 1 
                Dim qsID_int As Integer = 2 
                Dim dr As IDataReader = 'getting data from database here  
                Dim count As Integer = 0 
                While dr.Read()  
                    count += 1  
                    Dim aDock As New RadDock()  
                    aDock.DockMode = DockMode.Docked  
                    aDock.UniqueName = CStr(dr.Item("qID_int"))  
                    aDock.ID = CStr(dr.Item("qID_int"))  
                    Dim lblText As New Label()  
                    lblText.Text = CStr(dr.Item("lt_varchar")) + "<BR>"  
                    aDock.ContentContainer.Controls.Add(lblText)  
                    Select Case CStr(dr.Item("UI_varchar")).ToLower()  
                        Case "textbox"  
                            Dim txtControl As New RadTextBox  
                            aDock.ContentContainer.Controls.Add(txtControl)  
                            Dim editCMD As New DockCommand  
                            editCMD.Name = "editCMD" 
                            editCMD.Text = "Edit" 
                            editCMD.CssClass = "pullEditImage" 
                            editCMD.AutoPostBack = True 
                            aDock.Commands.Add(editCMD)  
                        Case "dropdownlist"  
                            Dim ddlControl As New DropDownList()  
                            aDock.ContentContainer.Controls.Add(ddlControl)  
                            Dim editCMD As New DockCommand  
                            editCMD.Name = "editCMD" 
                            editCMD.Text = "Edit" 
                            editCMD.CssClass = "pullEditImage" 
                            editCMD.AutoPostBack = True 
                            aDock.Commands.Add(editCMD)  
                        Case "radiobuttonlist"  
                            Dim rblControl As New RadioButtonList()  
                            aDock.ContentContainer.Controls.Add(rblControl)  
                            Dim editCMD As New DockCommand  
                            editCMD.Name = "editCMD" 
                            editCMD.Text = "Edit" 
                            editCMD.CssClass = "pullEditImage" 
                            editCMD.AutoPostBack = True 
                            aDock.Commands.Add(editCMD)  
                        Case "checkbox"  
                            Dim chControl As New CheckBox  
                            aDock.ContentContainer.Controls.Add(chControl)  
                            Dim editCMD As New DockCommand  
                            editCMD.Name = "editCMD" 
                            editCMD.Text = "Edit" 
                            editCMD.CssClass = "pullEditImage" 
                            editCMD.AutoPostBack = True 
                            aDock.Commands.Add(editCMD)  
                        Case "label"  
                            Dim editCMD As New DockCommand  
                            editCMD.Name = "editCMD" 
                            editCMD.Text = "Edit" 
                            editCMD.CssClass = "pullEditImage" 
                            editCMD.AutoPostBack = True 
                            aDock.Commands.Add(editCMD)  
                    End Select  
                    Dim delCMD As New DockCommand()  
                    delCMD.Name = "deleteCMD" 
                    delCMD.CssClass = "pullCrossImage" 
                    delCMD.Text = "Delete" 
                    delCMD.AutoPostBack = True 
                    delCMD.OnClientCommand = "delCustomCommand" 
                    aDock.Commands.Add(delCMD)  
                    AddHandler aDock.Command, AddressOf dock_Command  
                    aDock.DefaultCommands = Dock.DefaultCommands.None  
                    Dim triger As New AsyncPostBackTrigger()  
                    triger.ControlID = aDock.ID  
                    triger.EventName = "" 
                    uPanel.Triggers.Add(triger)  
                    rdZone.Controls.Add(aDock)  
                End While  
                dr.Dispose()  
                If count = 0 Then  
                    lblmsg.Text = "There are no yet." 
                End If  
            Catch ex As Exception  
                Dim exp As New exHandle  
                lblmsg.Text = exp.processExp(ex, "", Now)  
            End Try  
        End Sub  
 
 
 
        Sub dock_Command(ByVal sender As Object, ByVal e As DockCommandEventArgs)  
           If e.Command.Name = "deleteCMD" Then  
                    'do the delete bit here  
           ElseIf e.Command.Name = "editCMD" Then  
                    'open window to edit the question  
                    Dim nw As New RadWindow  
                    nw.ID = "asdfasdfsd" 
                    nw.NavigateUrl = "./previews.aspx?show=DDLPropertiesCTL" 
                    nw.VisibleOnPageLoad = True 
                    Dim rwm As RadWindowManager = CType(Page.FindControl("RadWindowManager1"), RadWindowManager)  
                    rwm.Windows.Add(nw)  
           End If  
        End Sub  
 
 

Here is the main ASPX page where multiview is located;

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mainHub.aspx.vb" Inherits="mainHubClass" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="radT" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
    <link href="style.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="overlib421/overlib.js"></script> 
</head> 
 
<body> 
    <form id="form1" runat="server">  
        <script type="text/javascript">  
        function openWin(args,width,height)  
        {  
            var oWnd = radopen(args, "RadWindow1");  
            oWnd.setSize(width,height);  
            oWnd.center();  
            oWnd.add_close(OnClientClose);  
        }  
          
        function OnClientClose(oWnd)  
        {  
            window.location.reload();  
        }  
        function GetRadWindow()  
        {  
            var oWindow = null;  
            if (window.radWindow) oWindow = window.radWindow;  
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
            return oWindow;  
        }        
         
        function returnToParent()  
        {  
            var oWnd = GetRadWindow();  
            oWnd.close();                 
        }  
   
//        function confirmCallBackFn(arg)  
//        {  
//            if (arg.toString() == 'false')  
//            {  
//                radconfirm('Do you want to add another question set?', confirmCallBackFnQset, 330, 100,null,'Question Set'); return false;              
//            }              
//        }  
//          
//        function confirmCallBackFnQset(arg)  
//        {  
//            if (arg.toString() == 'false')  
//            {  
//                radconfirm('Do you want to add another section?', confirmCallBackFnSection, 330, 100,null,'Section'); return false;   
//            }  
//            else  
//            {  
//                window.location="./addQuestionSets.aspx";  
//            }  
//        }  
//          
//        function confirmCallBackFnSection(arg)  
//        {  
//            if (arg.toString() == 'false')  
//            {  
//                radconfirm('Sections are complete now.<BR>Press Ok to go to products page, Cancel to go to Main page.', confirmCallBackFnRedirect, 330, 100,null,'Redirect'); return false;  
//            }  
//            else  
//            {  
//                window.location="./addSections.aspx";  
//            }  
//        }  
//          
//        function confirmCallBackFnRedirect(arg)  
//        {  
//            if (arg.toString() == 'false')  
//            {  
//                returnToParent(); return false;  
//                //window.location="./selfClose.aspx";  
//            }  
//            else  
//            {  
//                window.location="./addProducts.aspx";  
//            }  
//        }  
        </script> 
  <asp:ScriptManager id="ScriptManager" runat="server"/>      
             <radT:RadWindowManager Modal="true" Behaviors="Maximize" KeepInScreenBounds="true" 
     VisibleStatusbar="false" ID="RadWindowManager1" 
            ShowContentDuringLoad="true" runat="server" Skin="Default"   
            ReloadOnShow="True">  
 
        </radT:RadWindowManager>   
          
          
     <radT:RadAjaxLoadingPanel ID="ldPanel" runat="server" Transparency="50"   
            InitialDelayTime="0" BackColor="White" Font-Bold="True" Font-Size="Medium">  
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading7.gif") %>' style="margin-top: 75px;" /> 
        </radT:RadAjaxLoadingPanel> 
  <radT:RadAjaxPanel runat="server" ID="rdPanel" LoadingPanelID="ldPanel">  
       
        <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> 
    <radT:RadTabStrip ID="rtStrip" SelectedIndex="0" runat="server" MultiPageID="rmPage" 
     Skin="Sunset" CausesValidation="False">  
    </radT:RadTabStrip> 
    <radT:RadMultiPage ID="rmPage" runat="server" SelectedIndex="0" CssClass="multiPage" RenderSelectedPageOnly="True">  
    </radT:RadMultiPage> 
      
  </radT:RadAjaxPanel> 
    </form> 
</body> 
</html> 
 

Thats almost everything. Please have a look and let me know the problem.

Thanks
Atiq
0
Georgi Tunev
Telerik team
answered on 12 Aug 2008, 07:15 AM
Hi Atiq,

In your code I see that you are using Ajax panel, however RadWindowManager is not ajaxified - that is why it cannot open the RadWindow. Your code for opening the window is fine, but you need to update the RadWindowManager when making an Ajax call as well.



Greetings,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Atiq Ur Rehman
Top achievements
Rank 1
answered on 12 Aug 2008, 08:44 AM
hi, a little code help would be very helpfull, I am very dumb in javascript code.

Thanks
0
Georgi Tunev
Telerik team
answered on 12 Aug 2008, 09:46 AM
Hello again Atiq,

Just put the RadWindowManager in the Ajax Panel that you are using.


All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Atiq Ur Rehman
Top achievements
Rank 1
answered on 12 Aug 2008, 10:16 AM
Hi, I have tried that but that doesn't work. If I move radwindow in the panel, it only opens the window once and gives a javascript error on the browser which says
"Sys.ArgumentNullException: Value cannot be null. Parameter name: panelsUpdated[0]"
and then you can't open any window again unless you go back and come back to the page again.
Any suggestions?

Thanks
Atiq
0
Georgi Tunev
Telerik team
answered on 15 Aug 2008, 11:08 AM
Hello Atiq Ur Rehman,

The UpdatePanel is self-contained/self-updating control just like the AjaxManager. For such scenarios, you would have to either wrap both controls (initiator and updated) in one and the same UpdatePanel/RadAjaxPanel.
For convenience I attached a small sample (non-DNN)
to this thread that shows this approach and uses your code - I hope this helps.


Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Atiq Ur Rehman
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Atiq Ur Rehman
Top achievements
Rank 1
Share this question
or