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

adding controls dynamically to dynamically created docks

3 Answers 151 Views
Dock
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 25 Jul 2008, 03:44 PM
Hi,

I am creating docks dynamically and adding asp controls to them such as textboxes, dropdownlist etc It's working fine the only problem is that it doesn't show Textbox with rad form decorator, it shows normal textboxes only it doesn't show multiline textboxes. If i remove radform decorator from the page it shows the multiline textboxes.

Can anyone please help me out here what could be going wrong?

Thanks
Atiq

3 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 28 Jul 2008, 10:49 AM
Hello Atiq,

We were not able to reproduce the issue you describe on our side testing with a simple test page. Could you please send us some code snippets or a sample page which reproduces the problem? What kind of multiline textboxes do you use? At what stage in the page life cycle do you dynamically create the docks? Please, make sure that you have set ids to all controls you add on the page. We will be glad to help you but we need your assistance to reproduce the problem locally.

Looking forward to hearing form you,
Sophy
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 30 Jul 2008, 10:18 AM
Hi,

Here is the code.

.aspx file

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="addQuestions.aspx.vb" Inherits="Tonyg.SchemeShop.Admin.addQuestions" %> 
 
<%@ 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>Questions</title> 
    <link href="style.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="overlib421/overlib.js"></script> 
 <style type="text/css">     
   .rdContent     
   {      
        height:100%;      
   }   
   .rddd  
   {   
        width:100%;  
   }    
   .rdTextBox  
   {  
        height:100%;  
   }  
    </style>    
 
</head> 
<body> 
 
    <form id="form1" runat="server">     
        <asp:ScriptManager id="ScriptManager" runat="server"/>    
            <radT:RadWindowManager Modal="true" Behaviors="Pin" KeepInScreenBounds="true" 
     VisibleStatusbar="false" ID="RadWindowManager1" 
            ShowContentDuringLoad="true" runat="server" Skin="Default">  
        </radT:RadWindowManager> 
 <radT:radformdecorator id="FormDecorator1" runat="server" decoratedcontrols="CheckBoxes, RadioButtons, Buttons" 
            skin="Sunset">  
        </radT:radformdecorator> 
          
        <script type="text/javascript">  
         function openWin(args,width,height)  
        {  
            var oWnd = radopen(args, "RadWindow1");  
            oWnd.setSize(width,height);  
            oWnd.center();  
            //set a function to be called when RadWindow is closed  
            oWnd.add_close(OnClientClose);  
        }  
        function openEditWin(sender, eventArgs)  
        {  
            var oWnd = radopen("./somepage.aspx?i=" + sender.get_uniqueID(), "RadWindow1");  
            oWnd.setSize(640,520);  
            oWnd.center();  
            //set a function to be called when RadWindow is closed  
            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()  
        {  
            //get a reference to the RadWindow  
            var oWnd = GetRadWindow();  
            //refresh and close the RadWindow    
            //oWnd.Reload();            
            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="./asdf.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="./asdf.aspx";  
            }  
        }  
          
        function confirmCallBackFnRedirect(arg)  
        {  
            if (arg.toString() == 'false')  
            {  
                returnToParent(); return false;  
                //window.location="./asdfd.aspx";  
            }  
            else  
            {  
                window.location="./sdfdf.aspx";  
            }  
        }  
        function CustomCommand(dock, args)  
        {  
            //You can implement your custom logic in this method  
            if (!confirm("Are you sure you want to delete this question?"))  
            {  
                args.set_cancel(true);  
            }  
        }   
        </script> 
 
          
 
    <table width="100%" id="notAllowed" runat="server">  
    <tr> 
    <td>You don't have permission to view this page. Please contact broker 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> 
      
               
            <div id="nav-wrap"><div id="nav">         
        <ul> 
            <li>Business Class Registration</li> 
            <li>Sections</li> 
            <li>Question Sets</li> 
            <li id="current">Questions</li>   
        </ul>     
    </div></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">  
     
        </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" />--%> 
      
</td> 
<td> 
 
</td> 
<td align="right">  
    &nbsp;&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="Finish"   
            Width="120px" /> 
              
            </td> 
</tr> 
</table> 
 
    </fieldset> 
  </asp:Panel> 
     
    </form> 
      
</body> 
</html> 


aspx.vb code

    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 User.Identity.IsAuthenticated Then  
                Dim exHandle As New exHandle  
                If (exHandle.checkPermissions(User.Identity.Name) = True) Then  
                    notAllowed.Visible = False 
                    mainPNL.Visible = True 
                    If Session("bcID_int") Is Nothing Or _  
                    Session("sid_int") Is Nothing Or _  
                    Session("qsid_int") Is Nothing Then  
                        mainPNL.Visible = False 
                        notAllowed.Visible = True 
                    Else  
                        If Not IsPostBack Then  
                            createNodes()  
                        End If  
                    End If  
                Else  
                    mainPNL.Visible = False 
                    notAllowed.Visible = True 
                End If  
                Else  
                    mainPNL.Visible = False 
                    notAllowed.Visible = True 
                End If  
        End Sub  
 
 
 
  Sub createDocks()  
            Try  
                Dim bcid_int As Integer = CInt(Session("bcid_int"))  
                Dim sid_int As Integer = CInt(Session("sid_int"))  
                Dim qsid_int As Integer = CInt(Session("qsid_int"))  
                Dim dr As IDataReader = 'getting from database here  
                Dim count As Integer = 0 
                While dr.Read()  
                    count += 1  
                    Dim aDock As New RadDock()  
                    aDock.DockMode = DockMode.Docked  
                    aDock.UniqueName = Guid.NewGuid().ToString()  
                    aDock.ID = CStr(dr.Item("qid_int"))  
                    Dim lblText As New Label()  
                    lblText.Text = CStr(dr.Item("lt")) + "<BR>"  
                    aDock.ContentContainer.Controls.Add(lblText)  
                    Select Case CStr(dr.Item("ui"))  
                        Case "TextBox"  
                            Dim txtControl As New RadTextBox  
                            If CInt(dr.Item("TextBoxWidth")) > 0 Then  
                                txtControl.Width = System.Web.UI.WebControls.Unit.Pixel(dr.Item("TextBoxWidth_int"))  
                            End If  
                            If CInt(dr.Item("TextBoxHeight")) > 0 Then  
                                txtControl.Height = System.Web.UI.WebControls.Unit.Pixel(dr.Item("TextBoxHeight_int"))  
                            End If  
                            If CBool(dr.Item("MultLine")) Then  
                                txtControl.TextMode = TextBoxMode.MultiLine  
                            End If  
                            'txtControl.CssClass = "rdTextBox" 
                            aDock.ContentContainer.Controls.Add(txtControl)  
                        Case "DropDownList"  
                            Dim ddlControl As New DropDownList()  
                            Dim drItems As IDataReader = 'getting from database here  
                            While drItems.Read()  
                                Dim ddlItem As New ListItem(drItems.Item("OptionText"), drItems.Item("OptionValue"))  
                                ddlControl.Items.Add(ddlItem)  
                                Try  
                                    If drItems.Item("Default") = 1 Then  
                                        ddlControl.Items.FindByText(drItems.Item("OptionText")).Selected = True 
                                    End If  
                                Catch  
                                End Try  
                            End While  
                            drItems.Dispose()  
                            ddlControl.CssClass = "rddd" 
                            aDock.ContentContainer.Controls.Add(ddlControl)  
                        Case "RadioButtonList"  
                            Dim rblControl As New RadioButtonList()  
                            Dim drItems As IDataReader = 'getting from database here  
                            While drItems.Read()  
                                Dim ddlItem As New ListItem(drItems.Item("OptionText"), drItems.Item("OptionValue"))  
                                rblControl.Items.Add(ddlItem)  
                                Try  
                                    If drItems.Item("Default") = 1 Then  
                                        rblControl.Items.FindByText(drItems.Item("OptionText_varchar")).Selected = True 
                                    End If  
                                Catch  
                                End Try  
                            End While  
                            drItems.Dispose()  
                            rblControl.CssClass = "button" 
                            aDock.ContentContainer.Controls.Add(rblControl)  
                        Case "Checkbox"  
                            Dim chControl As New CheckBox  
                            If LCase(dr.Item("TextBoxDefault_varchar")) = "true" Then  
                                chControl.Checked = True 
                            End If  
                            aDock.ContentContainer.Controls.Add(chControl)  
                    End Select  
                    'aDock.AutoPostBack = True 
                    'aDock.CommandsAutoPostBack = False 
                    Dim delCMD As New DockCommand()  
                    delCMD.Name = "deleteCMD" 
                    delCMD.CssClass = "pullCrossImage" 
                    delCMD.Text = "Delete" 
                    delCMD.AutoPostBack = True 
                    delCMD.OnClientCommand = "CustomCommand" 
                    aDock.Commands.Add(delCMD)  
                    Dim editCMD As New DockCommand  
                    editCMD.Name = "editCMD" 
                    editCMD.Text = "Edit" 
                    editCMD.CssClass = "pullEditImage" 
                    editCMD.AutoPostBack = True 
                    editCMD.OnClientCommand = "openEditWin" 
                    aDock.Commands.Add(editCMD)  
                    AddHandler aDock.Command, AddressOf dock_Command  
                    aDock.DefaultCommands = Dock.DefaultCommands.None  
                    'aDock.Width = 600 
                    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 questions added 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 Session("bcid_int") Is Nothing Or _  
            Session("sid_int") Is Nothing Or _  
            Session("qsid_int") Is Nothing Then  
                mainPNL.Visible = False 
                notAllowed.Visible = True 
            Else  
                If e.Command.Name = "deleteCMD" Then  
 
                End If  
            End If  
        End Sub 

i think this should help you in solving the problem!

Thanks
Atiq
0
Sophy
Telerik team
answered on 30 Jul 2008, 03:51 PM
Hi Atiq,

I created a sample page based on the code you have sent us, however, I had to comment some lines which required missing resources. I was not able to reproduce the issue you describe. Is the problem which you observe that multiline textboxes does not appear inside the RadDock but they appear when you remove the RadFormDecorator? Please, find attached my test page based on the provided code snippets and test whether you can reproduce the issue with the enclosed page on your side. Let me know if I am missing something. What browser so you use? I tested the attached page in IE and Firefox and the problem did not exist.

Best wishes,
Sophy
the Telerik team

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