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

cratin raddocklayout in a contentpage dynamically

2 Answers 45 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 15 Oct 2008, 06:35 AM
sir ,

I tried the below code

Function

CreateJavaScriptFunctionCall(ByVal dock As RadDock) As String

 

Dim dockHandleID As String = ""

 

 

 

For Each contrl As Control In dock.ContentContainer.Controls

 

 

 

If TypeOf contrl Is LiteralControl Then

 

 

 d

ockHandleID = contrl.ClientID

 

 

End If

 

 n

ext

 

Return "changeRadDockHandle('" + dock.ClientID + "','" + dockHandleID + "')"

 

End Function

Protected
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

 

Dim smExists As Boolean = False

 

 

For Each contrl As Control In Page.Form.Controls

 

 

 

If TypeOf contrl Is ScriptManager Then

 

 

 

smExists = True

 

 

Exit For

 

 

End If

 

 

Next

 

 

If Not (smExists) Then

 

 

Dim sm As New ScriptManager()

 

 Page.Form.Controls.Add(sm)

Page.Header.Controls.Add(

 

New LiteralControl("<script language='javascript'> function changeRadDockHandle(dockID,handleID){var dock = $find(dockID)dock.set_handle(document.getElementById(handleID))} </script>"))

 

End If

 

 

Dim layout As New RadDockLayout()

 

 layout.ID =

"layout"

 

 

Page.Form.Controls.Add(layout)

 

 

Dim zone As New RadDockZone()

 

 layout.Controls.Add(zone)

 

Dim zone2 As New RadDockZone()

 

 layout.Controls.Add(zone2)

 

Dim UpdatePanl As New UpdatePanel()

 

 UpdatePanl.ID =

"UpdatePanel1"

 

 

layout.Controls.Add(UpdatePanl)

 

 

zone.ID = "zone"

 

 

zone2.ID = "zone2"

 

 

Dim dock As New RadDock()

 

 

dock.ID = "dock"

 

 

dock.ContentContainer.Controls.Add(New LiteralControl("blahblah"))

 

 dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None

dock.DockHandle = DockHandle.None

dock.OnClientInitialize = CreateJavaScriptFunctionCall(dock)

zone.Controls.Add(dock)

 

End Sub

But its not working,simply showing the literal control only and a javascript error
Object Expected

Thanks

 

 

2 Answers, 1 is accepted

Sort by
0
Stanimir
Telerik team
answered on 17 Oct 2008, 05:51 PM
Hi Priya,

You should go through the following steps:

1. You should use the ScriptManager's RegisterStartupScript method to register your javascript:

sm.RegisterStartupScript(
Page.Header,
Me.[GetType](),
"DockSetHandle",
"function changeRadDockHandle(dock, args){dock.set_handle(document.getElementById('dockLable1'));}",
True) 

2. You should assign the name of a javascript function to the OnClientInitialize property of the doc:
dock.OnClientInitialize = "changeRadDockHandle" 
The arguments of the function doc, args will be given automatically.

3. When you set a handle to a dock it must be e valid DOM element. In the example below you will see that I use a <label> element.

Here is sample of the Page_Load Method.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
        Dim sm As New ScriptManager()  
        Page.Form.Controls.Add(sm)  
        sm.RegisterStartupScript(
            Page.Header,
            Me.[GetType](),
            "DockSetHandle",
            "function changeRadDockHandle(dock, args){dock.set_handle(document.getElementById('dockLable1'));}",
            True
        )  
 
        Dim layout As New RadDockLayout()  
        layout.ID = "layout" 
        Page.Form.Controls.Add(layout)  
        Dim zone As New RadDockZone()  
        layout.Controls.Add(zone)  
        Dim zone2 As New RadDockZone()  
        layout.Controls.Add(zone2)  
        Dim UpdatePanl As New UpdatePanel()  
        UpdatePanl.ID = "UpdatePanel1" 
        layout.Controls.Add(UpdatePanl)  
        zone.ID = "zone" 
        zone2.ID = "zone2" 
        Dim dock As New RadDock()  
        dock.ID = "dock" 
        dock.ContentContainer.Controls.Add(New LiteralControl("<label id='dockLable1'>blahblah</>"))  
        dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None  
        dock.DockHandle = DockHandle.None  
        dock.OnClientInitialize = "changeRadDockHandle" 
        zone.Controls.Add(dock)  
    End Sub 


Regards,
Stanimir
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 18 Oct 2008, 05:45 AM
Thnaks alot for ur detailed help
I also tried this

Dim

strScript As String

 

strScript =

"<script language=javascript>"

 

strScript +=

"function SetTheDockHandle(dock, args){ var calendar = $find('<%= dock.ClientID %>');dock.set_handle(calendar.get_element());}"

 

strScript +=

"<"

 

strScript +=

"/script>"

 

Page.RegisterStartupScript(

"MSGE", strScript)
and was working fine

 

Tags
Dock
Asked by
Priya
Top achievements
Rank 1
Answers by
Stanimir
Telerik team
Priya
Top achievements
Rank 1
Share this question
or