Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
128 views
I have successfully implemented from your sample a portal page using the dock that saves and reloads from the database dependant on user. However the user has different roles and therefore different portal pages. This is selected by a dropdown on the page.

The problem I am having is as the dynamically loaded dock state is actioned on the initialization of the page the new selected value of the dropdown is not available until the load stage.

Can you please advise how I can load the dock from the database dependant on the selected value of the dropdown.

Thanks

Mark

Private _conn As New SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)  
 
    Private ReadOnly Property CurrentDockStates() As List(Of DockState)  
        Get 
            'Get saved state string from the database - set it to dockState variable for example   
            Dim dockStatesFromDB As String = "" 
 
            _conn.Open()  
            Dim command As New SqlCommand("select State from States where id='" + Me.DropDownList1.SelectedValue.ToString + "'", _conn)  
            dockStatesFromDB = command.ExecuteScalar().ToString()  
            _conn.Close()  
 
            Dim _currentDockStates As New List(Of DockState)()  
            Dim stringStates As String() = dockStatesFromDB.Split("|"c)  
            For Each stringState As String In stringStates  
                If stringState.Trim() <> String.Empty Then 
                    _currentDockStates.Add(DockState.Deserialize(stringState))  
                End If 
            Next 
            Return _currentDockStates  
        End Get 
    End Property 
 
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init  
 
        'Recreate the docks in order to ensure their proper operation  
        Dim i As Integer = 0  
        While i < CurrentDockStates.Count  
            If CurrentDockStates(i).Closed = False Then 
                Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))  
                'We will just add the RadDock control to the RadDockLayout.  
                ' You could use any other control for that purpose, just ensure  
                ' that it is inside the RadDockLayout control.  
                ' The RadDockLayout control will automatically move the RadDock  
                ' controls to their corresponding zone in the LoadDockLayout  
                ' event (see below).  
 
                'We want to save the dock state every time a dock is moved.  
                CreateSaveStateTrigger(dock)  
                'Load the selected widget  
                LoadWidget(dock)  
 
                RadDockLayout1.Controls.Add(dock)  
            End If 
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)  
        End While 
    End Sub 
 
    Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)  
        'Populate the event args with the state information. The RadDockLayout control  
        ' will automatically move the docks according that information.  
        For Each state As DockState In CurrentDockStates  
            e.Positions(state.UniqueName) = state.DockZoneID  
            e.Indices(state.UniqueName) = state.Index  
        Next 
    End Sub 
 
    Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)  
        Dim stateList As List(Of DockState) = Me.RadDockLayout1.GetRegisteredDocksState()  
        Dim serializedList As New StringBuilder()  
        Dim i As Integer = 0  
 
        While i < stateList.Count  
            serializedList.Append(stateList(i).ToString())  
            serializedList.Append("|")  
            System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)  
        End While 
 
        Dim dockState As String = serializedList.ToString()  
        If dockState.Trim() <> [String].Empty Then 
            _conn.Open()  
            Dim command As New SqlCommand([String].Format("update States set State='{0}' where id='" + Me.DropDownList1.SelectedValue.ToString + "'", dockState), _conn)  
            command.ExecuteNonQuery()  
            _conn.Close()  
        End If 
    End Sub 
 
    Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock  
        Dim dock As New RadDock()  
        dock.DockMode = DockMode.Docked  
        dock.ID = String.Format("RadDock{0}", state.UniqueName)  
        dock.ApplyState(state)  
        dock.EnableAnimation = True 
 
        dock.Commands.Add(New DockCloseCommand)  
        dock.Commands.Add(New DockExpandCollapseCommand())  
 
        Return dock  
    End Function 
 
    Private Function CreateRadDock() As RadDock  
        Dim docksCount As Integer = CurrentDockStates.Count  
 
        Dim dock As New RadDock()  
        dock.DockMode = DockMode.Docked  
        dock.UniqueName = Guid.NewGuid().ToString()  
        dock.ID = String.Format("RadDock{0}", dock.UniqueName)  
        dock.Title = Replace(Replace(DroptDownWidget.SelectedItem.Text, ".ascx", ""), "_", " ")  
        dock.EnableAnimation = True 
 
        dock.Text = String.Format("Added at {0}", DateTime.Now)  
        dock.Width = Unit.Pixel(386)  
 
        dock.Commands.Add(New DockCloseCommand())  
        dock.Commands.Add(New DockExpandCollapseCommand())  
        dock.CommandsAutoPostBack = True 
 
        Return dock  
    End Function 
 
    Private Sub CreateSaveStateTrigger(ByVal dock As RadDock)  
        'Ensure that the RadDock control will initiate postback  
        ' when its position changes on the client or any of the commands is clicked.  
        'Using the trigger we will "ajaxify" that postback.  
        dock.AutoPostBack = True 
        dock.CommandsAutoPostBack = True 
 
        Dim updatedControl As New AjaxUpdatedControl()  
        updatedControl.ControlID = "Panel1" 
 
        Dim setting1 As New AjaxSetting(dock.ID)  
        setting1.EventName = "DockPositionChanged" 
        setting1.UpdatedControls.Add(updatedControl)  
 
        Dim setting2 As New AjaxSetting(dock.ID)  
        setting2.EventName = "Command" 
        setting2.UpdatedControls.Add(updatedControl)  
 
        RadAjaxManager1.AjaxSettings.Add(setting1)  
        RadAjaxManager1.AjaxSettings.Add(setting2)  
 
 
    End Sub 
 
    Private Sub LoadWidget(ByVal dock As RadDock)  
        If String.IsNullOrEmpty(dock.Tag) Then 
            Return 
        End If 
        Dim widget As Control = LoadControl(dock.Tag)  
        dock.ContentContainer.Controls.Add(widget)  
    End Sub 
 
    Protected Sub ButtonAddDock_Click(ByVal sender As Object, ByVal e As EventArgs)  
        Dim dock As RadDock = CreateRadDock()  
        'find the target zone and add the new dock there  
        Dim dz As RadDockZone = DirectCast(XMLUtilities.FindControlRecursive(Master, "RadDockZone1"), RadDockZone)  
 
        dz.Controls.Add(dock)  
 
        CreateSaveStateTrigger(dock)  
 
        'Load the selected widget in the RadDock control  
        dock.Tag = DroptDownWidget.SelectedValue  
 
        LoadWidget(dock)  
        ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "MoveDock", String.Format("function _moveDock() {{" & vbCr & vbLf & vbTab & vbTab & vbTab & "        " & vbTab & "Sys.Application.remove_load(_moveDock);" & vbCr & vbLf & vbTab & vbTab & vbTab & vbTab & "        $find('{1}').dock($find('{0}'),{2});" & vbCr & vbLf & vbTab & vbTab & vbTab & "            }};" & vbCr & vbLf & vbTab & vbTab & vbTab & "            Sys.Application.add_load(_moveDock);", "$find('<%= RadDock1.ClientID %>');", "RadDockZone1", dz.Docks.Count), True)  
 
    End Sub 
Pero
Telerik team
 answered on 03 Feb 2010
0 answers
119 views

Hi Team,

I am not able to retain value of combobox when i click on "Click Me" in my code. Please help me. My code as  below.


Code Behind Code:-

 
Partial Class _Default  
    Inherits System.Web.UI.Page  
 
 
    Protected Sub rcbSections_ItemDataBound(ByVal sender As Object, ByVal e As RadComboBoxItemEventArgs) Handles rcbCat.ItemDataBound  
        Dim CustomExamID As String = CType(e.Item.FindControl("chk"), CheckBox).Attributes("CategoryID")  
 
        If ViewState("CategoryID") <> CustomExamID Then 
 
            ViewState("CategoryID") = CustomExamID  
 
            Dim CustomExamTitle As String = CType(e.Item.FindControl("chk"), CheckBox).Attributes("CategoryName")  
 
            Dim objSectionItem As New RadComboBoxItem  
            objSectionItem.Value = CustomExamID  
            objSectionItem.Text = CustomExamTitle  
            objSectionItem.IsSeparator = True 
 
            rcbCat.Items.Insert(e.Item.Index, objSectionItem)  
            rcbCat.Items(e.Item.Index - 1).Controls.Remove(rcbCat.Items(e.Item.Index - 1).FindControl("chk"))  
 
            Dim objTitle As New LiteralControl()  
            objTitle.ID = "lcCategoryName" 
            objTitle.Text = CustomExamTitle  
            rcbCat.Items(e.Item.Index - 1).Controls.Add(objTitle)  
 
        End If 
 
    End Sub 
 
    Private Sub FillCategory()  
 
        Dim dtMaster As New DataTable("Item")  
 
        dtMaster.Columns.Add("CategoryID")  
        dtMaster.Columns.Add("CategoryName")  
        dtMaster.Columns.Add("SubCategoryID")  
        dtMaster.Columns.Add("SubCategoryName")  
 
        For index As Integer = 1 To 10  
 
            For index1 As Integer = 1 To 3  
                Dim drNew As DataRow  
                drNew = dtMaster.NewRow()  
                drNew("CategoryID") = index  
                drNew("CategoryName") = "CategoryName" + index.ToString  
 
                drNew("SubCategoryID") = index1  
                drNew("SubCategoryName") = "SubCategoryName" + index1.ToString  
                dtMaster.Rows.Add(drNew)  
            Next 
 
        Next 
 
        rcbCat.DataSource = dtMaster  
        rcbCat.DataTextField = "SubCategoryName" 
        rcbCat.DataValueField = "SubCategoryID" 
        rcbCat.DataBind()  
 
    End Sub 
 
 
    Protected Sub btnFillCat_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFillCat.Click  
        FillCategory()  
    End Sub 
End Class 
 


Design Code :-

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
 
<!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>  
</head> 
<telerik:radscriptblock runat="server" id="scriptBlock">  
 
 <script type="text/javascript">  
        var cancelDropDownClosing = false;  
 
        function onDropDownClosing() {  
            cancelDropDownClosing = false;  
        }  
        function onSectionCheckBoxClick() {  
 
            var combo = $find("<%= rcbCat.ClientID %>");  
            //prevent second combo from closing  
            cancelDropDownClosing = true;  
            //holds the text of all checked items  
            var text = "";  
            //holds the values of all checked items  
            var values = "";  
            //get the collection of all items  
            var items = combo.get_items();  
            //enumerate all items  
            for (var i = 0; i < items.get_count(); i++) {  
                var item = items.getItem(i);  
                //get the checkbox element of the current item  
                var chk1 = $get(combo.get_id() + "_i" + i + "_chk");  
 
                if (chk1) {  
                    if (chk1.checked) {  
                        text += item.get_text() + ",";  
                        values += item.get_value() + ",";  
                    }  
                }  
            }  
            //remove the last comma from the string  
            text = removeLastComma(text);  
            values = removeLastComma(values);  
 
            if (text.length > 0) {  
                //set the text of the combobox  
                combo.set_text(text);  
                combo.set_value(values);  
            }  
            else {  
                //all checkboxes are unchecked  
                //so reset the controls  
                combo.set_text("All Category");  
                combo.set_value("All");  
            }  
        }  
 
        function StopPropagation(e) {  
            if (!e) {  
                e = window.event;  
            }  
            e.cancelBubble = true;  
        }  
 
        //this method removes the ending comma from a string  
        function removeLastComma(str) {  
            return str.replace(/,$/, "");  
        }  
    </script> 
     
    </telerik:radscriptblock> 
<body> 
    <form id="form1" runat="server">  
    <div> 
             <div style="color: Red;width:500px;text-align:justify;">  
           <b>Note:- </b> First Fill the Combobox by clicking on "Fill Category" then select calegories  
            from combobox using checkbox. After this click on "Click Me". Then open the combobox  
            you will see the Separator have checkbox and category name will disapper.  
        </div> 
        <br /> 
            
        <asp:Button runat="server" Text="Fill Category" ID="btnFillCat" /><br /><br /> 
        <asp:Button runat="server" Text="Click Me" ID="btnClick" /> 
        <br /> 
        <br /> 
        <br /> 
        <telerik:radcombobox id="rcbCat" runat="server" height="140px" showtoggleimage="True" 
            highlighttemplateditems="true" onclientload="onSectionCheckBoxClick" width="290px" 
            style="vertical-align: middle;" expandanimation-type="None" collapseanimation-type="None" 
            allowcustomtext="false" onclientdropdownclosed="onDropDownClosing">  
            <ItemTemplate> 
                <div onclick="StopPropagation(event)">  
                    <asp:CheckBox runat="server" ID="chk" Text='<%# Eval("SubCategoryName") %>' Value='<%# Eval("SubCategoryID") %>' 
                        CategoryID='<%# Eval("CategoryID") %>' CategoryName='<%# Eval("CategoryName") %>' 
                        TextAlign="right" onclick="onSectionCheckBoxClick()"  /> 
                </div> 
            </ItemTemplate> 
        </telerik:radcombobox> 
    </div> 
    <telerik:radajaxmanager runat="server" id="ramTest">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="rcbCat">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rcbCat" LoadingPanelID="rlpCR" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:radajaxmanager> 
    </form> 
</body> 
</html> 
 


I am waiting for you reply.

Thanks

Chirag Patel

 

chirag
Top achievements
Rank 1
 asked on 03 Feb 2010
0 answers
93 views
in scheduler monthview  i can put the cursor in particular cell with out any appointment ..how can i open the tooltip....
Nagesh Mynedi
Top achievements
Rank 1
 asked on 03 Feb 2010
2 answers
121 views
// Find the RadControl client object, if null then exit the function  
sb.Append(String.Format("var co = $find(\"{0}\");", c.ClientID));  
sb.Append("if (co == null) return;");
 

When I register this code with the Page.ClientScript.RegisterStartupScript method it attempts to execute before the Telerik Control Javascript objects are created resulting in "co" being assigned a null value.  How do I register startup Javascript code that executes AFTER the Telerik javascript objects are created.
Eric
Top achievements
Rank 1
 answered on 03 Feb 2010
3 answers
118 views
Hi,

Pasting the following in the editor in Design mode:

Is parket te combineren met vloerverwarming? 
 
Ja, mits het parket hiertoe geschikt is, dan is het te combineren met vloerverwarming zowel als bijverwarming als hoofdverwarming 


Results in three different browsers in the following piece of HTML.

FireFox:
Is parket te combineren met vloerverwarming?<br /> 
<br /> 
Ja, mits het parket hiertoe geschikt is, dan is het te combineren met vloerverwarming zowel als bijverwarming als hoofdverwarming 
IE8:
<p>Is parket te combineren met vloerverwarming?</p> 
<p>Ja, mits het parket hiertoe geschikt is, dan is het te combineren met vloerverwarming zowel als bijverwarming als hoofdverwarming</p> 
Chrome:
<div>Is parket te combineren met vloerverwarming?</div> 
<div><br /> 
</div> 
<div>Ja, mits het parket hiertoe geschikt is, dan is het te combineren met vloerverwarming zowel als bijverwarming als hoofdverwarming</div> 
Why is the produced HTML browser dependent? I have tested this with the demo Editors on your website.

Thanks for your answer.

Marc


Dobromir
Telerik team
 answered on 03 Feb 2010
6 answers
153 views
Hi!

I'm trying to theme my Telerik controls via ASP.NET theming mechanism. I'm using 2008.2.723.35. We're using ASP.NET 3.5 and I've seen this being done in 2.0.  Below is my skinfile:

<%@ Register
Assembly="Telerik.Web.UI, Version=2008.2.723.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI"
TagPrefix="telerik" %>

<telerik:RadCalendar runat="server"></telerik:RadCalendar>

However, upon i compile i get the error:
Type 'Telerik.Web.UI.RadCalendar' is not defined. 

What's wrong here?

I should tell you that the site works otherwise, i.e. no problem loading the assembly and using the Telerik controls in the "normal" way.

Regards
Linus
Dimo
Telerik team
 answered on 03 Feb 2010
2 answers
1.1K+ views
I'm trying to use the RadGrid GridCheckboxColumn for the first time and the checkboxes are inert - they don't work.

<telerik:RadGrid ID="radGrid1" runat="server" Skin="Forest"     AllowFilteringByColumn="True"                           AllowPaging="True"   
    AllowSorting="True"   
    AutoGenerateColumns="False"   
    DataSourceID="ObjectDataSource1"   
    GridLines="None"   
    ShowGroupPanel="True">  
 
    <MasterTableView AllowMultiColumnSorting="True"   
    AutoGenerateColumns="False"   
    DataSourceID="ObjectDataSource1"   
    ShowFooter="True">  
          
        <RowIndicatorColumn> 
        <HeaderStyle Width="20px"></HeaderStyle> 
    </RowIndicatorColumn> 
 
    <ExpandCollapseColumn> 
        <HeaderStyle Width="20px"></HeaderStyle> 
    </ExpandCollapseColumn> 
      
        <Columns> 
        <telerik:GridCheckBoxColumn UniqueName="chkCol"   
            HeaderText="<center>Get<br/>Details</center>"   
            AllowFiltering="false"   
            AllowSorting="false"   
            Groupable="false">  
        <HeaderStyle Width="40px" ForeColor="#193300" Font-Bold="true" /> 
        </telerik:GridCheckBoxColumn> 
        </Columns> 
etc.... 

I copied this pretty much verbatum from one of the online examples.  I searched this forum without success of finding another case like this.  Does anybody have a clue as to why the checkboxes don't work (won't check)?

Thanks,
Mark
Mark Galbreath
Top achievements
Rank 2
 answered on 03 Feb 2010
2 answers
238 views
Hello,

We are using RadCombobox Load on Demand functionality along with ShowMoreResultBox True.
This is giving us To select next items.
Also we refered  http://www.telerik.com/community/forums/aspnet-ajax/combobox/radcombobox-pagination.aspx forum to clear the previous data. but now we are not having any functionality to get the previous records.

Kindly help us out to have to have previous and next both functionality with RadCombobox, as we are able to achieve only next functionality and not previous functionality.

Thanks.

Chanda.
Kalina
Telerik team
 answered on 03 Feb 2010
1 answer
113 views
Hi,

Should event handling work the same way for controls in a RadMenus templates as per normal asp.net?

I have

<telerik:RadMenu ID="RadMenu1" runat="server" Skin="Office2007" OnItemClick="RadMenu1_ItemClick">  
        <Items> 
            <telerik:RadMenuItem runat="server" Text="Link Type">  
                <Items> 
                    <telerik:RadMenuItem runat="server" Text="Test" Width="150px">  
                        <ItemTemplate> 
                            <asp:RadioButtonList ID="phrasepagetypeRadioButtonList" runat="server"   
                                Width="150px"   
                                onselectedindexchanged="phrasepagetypeRadioButtonList_SelectedIndexChanged">  
                                <asp:ListItem Value="99" Selected="True">All</asp:ListItem> 
                                <asp:ListItem Value="0">Product</asp:ListItem> 
                                <asp:ListItem Value="1">Inspect</asp:ListItem> 
                            </asp:RadioButtonList> 
                        </ItemTemplate> 
                    </telerik:RadMenuItem> 
                </Items> 
            </telerik:RadMenuItem> 
... and so on

and when I click the radio buttons no event fires, but when I click on the menu name I get the phrasepagetypeRadioButtonList_SelectedIndexChanged event firing and then the radmenu item clicked event afterwards????

protected

 

void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)

 

{

}

 

protected void phrasepagetypeRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)

 

{

}

Thanks
Matt

Shinu
Top achievements
Rank 2
 answered on 03 Feb 2010
3 answers
124 views
Hi,
I am using day templates to show images on certain days. I have a label in the dayTemplate but I am unable to access it in
DayRender event. I want to show the date as well as the image on the calendar cell.
Help is much appreciated.

Thanks!
Pavlina
Telerik team
 answered on 03 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?