Telerik Forums
UI for ASP.NET AJAX Forum
9 answers
260 views
Hi,

I think I misunderstand the usage of RadAjaxManager.AjaxRequest. My application uses a single RadAjaxManager in the masterpage and RadAjaxManagerProxies in the content pages. One of the content page contains a RadGrid which I want to rebind when a popup closes. This is what I did:

* Added the server-side delegate which rebinds the grid in the content page's Page_Load   method (RadAjaxManager.GetCurrent(Page).AjaxRequest +=new   RadAjaxControl.AjaxRequestDelegate(MyPage_AjaxRequest);)

* Created a clident-side script which performs the ajax request like this:
ajaxManager.ajaxRequest();

The problem is, that the client script is called but appearently no ajax request is performed. What's the problem here?

Best regards,
Robert
Aleksandar
Top achievements
Rank 1
 answered on 11 Oct 2008
1 answer
138 views
In attempting to use a treeview control that will use LoadOnDemand and get data from a web service that I have written, I tried to point the treeview to a web service in a different domain. Since I was attempting a cross-domain request, I got an error.

So, I have been researching proxy services, and how to use them.

I have created a web reference in my application that is using the treeview. That web reference points to the web service I created. But, how do I hook this to the treeview? Do I have to create an .asmx file in my application, and use that to "wrap" the functionality of the web service (then point the Path property of the treeview's WebServiceSettings entry to the new asmx file).

Or, is this approach completely wrong?

I haven't found a good explaination for this but, I hope it isn't too dumb of a question.

Thanks.
Roger
Top achievements
Rank 1
 answered on 10 Oct 2008
2 answers
218 views
This is a tricky/odd one. I am creating tabs and associated pageviews dynamically on the client-side. This works great. When the user closes the tab the tab and pageview are removed, again on the client-side. This also works great.

Here's the tricky part. I am creating an iframe inside the pageview. When the pageview is removed from the multipage, the iframe still exists on the page! This causes a problem because when you try to create another tab with the same ID I end up creating another iframe with the same ID and then FireFox gets confused and doesn't display the "correct" (newly created) iframe.

Here is a one page web site that demonstrates the problem. Run this page and click the "Check Tab" button first. You will see "123 not found" meaning that the iframe was not found. Click the "Add Tab" button then click "Check Tab" again. You will see "about:blank" which fine - the iframe exists and is displaying a blank page. Finally, click the "Close Tab" button then "Check Tab" again. You would expect to get "123 not found" but instead you get "null" - which indicates that the iframe still exists in the DOM.

Notice that it works as expected in IE and Chrome, but not in Fire Fox.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!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>  
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
        <script type="text/javascript">  
        function Main_GetTabStrip() {  
            return $find('<%= RadTabStrip1.ClientID %>');  
        }  
        function Main_GetMainMultiPage() {  
            return $find('<%= RadMultiPage1.ClientID%>');  
        }  
          
        function GetTab(tabId) {  
            var tabstrip = Main_GetTabStrip();  
            return tabstrip.findTabByValue(tabId);  
        }  
 
        function GetPageView(tabId) {  
            var multipage = Main_GetMainMultiPage();  
            return multipage.findPageViewByID(tabId);  
        }  
 
        function ShowTab(tabText, tabId, tabType) {  
            // See if the specified tab already exists.  
            var tab = GetTab(tabId);  
            if (!tab) {  
                // Tab doesn't exist, create a new one.  
                tab = new Telerik.Web.UI.RadTab();  
                tab.set_value(tabId);  
 
                // Add the new tab to the tab strip.  
                var tabstrip = Main_GetTabStrip();  
                tabstrip.get_tabs().add(tab);  
            }  
 
            // Set the tab text (title).  
            tab.set_text(tabText);  
 
            // "refresh" determines whether the tab contents must be refreshed.  
            // (e.g. new contents for an existing tab)  
            var refresh = false;  
 
            // See if the page view already exists.  
            var page = GetPageView(tabId);  
            if (!page) {  
                // Page view doesn't exist for this tab, create a new one.  
                page = new Telerik.Web.UI.RadPageView();  
                page.set_id(tabId);  
 
                // Add the new page view to the multi-page.  
                var multipage = Main_GetMainMultiPage();  
                multipage.get_pageViews().add(page);  
 
                // Create a hidden field inside the page view to hold the "TabType".  
                var dom = page.get_element();  
                dom.style.width = "100%";  
                dom.style.height = "100%";  
 
                var s = '<input id="' + tabId + '_TabType" type="hidden" value="' + tabType + '" />';  
                s += '  <iframe id="' + tabId + '_iframe" name="' + tabId + '_iframe" src="#" style="border: 0; width: 100%; height: 100%;" frameborder="0" height="100%" width="100%" scrolling="yes" />';  
                dom.innerHTML = s;  
 
                // Since this is a new page view, the contents should be refreshed.  
                refresh = true;  
            }  
            else {  
                // Page already exists. See if we need to refresh the contents.  
                var x = document.getElementById(tabId + '_TabType');  
                if (x.value != tabType) {  
                    // The TabType of the existing tab doesn't match the tabType  
                    // passed in to this function. That means that the same tab  
                    // is being used for different content, so we need to "refresh"  
                    // the tab contents.  
                    refresh = true;  
                    x.value = tabType;  
                }  
            }  
 
            // Make this tab the "selected" tab. Since the page view Id matches the           
            // tab Id, this also makes the associated page view visible.  
            tab.select();  
 
            //if (refresh) {  
                //document.getElementById(tabId + '_FrameLoading').style.display = 'block';  
                //document.getElementById(tabId + '_FrameContainer').style.display = 'none';  
 
                //var ifrm = top.frames[tabId + '_iframe'];  
                //ifrm.src = '/Merchants/Members/TabLoader.aspx?TabType='+tabType+'&TabId='+tabId;  
                //ifrm.location = '/Merchants/Members/TabLoader.aspx?TabType=' + tabType + '&TabId=' + tabId;  
            //}  
        }  
          
        function CloseTab(tabId) {  
            var seltab = null;  
 
            var tab = GetTab(tabId);  
            if (tab) {  
                if (tab.get_nextSibling() != null)  
                    seltab = tab.get_nextSibling();  
                else if (tab.get_previousSibling() != null)  
                    seltab = tab.get_previousSibling();  
 
                var tabstrip = Main_GetTabStrip();  
                tabstrip.get_tabs().remove(tab);  
            }  
            var page = GetPageView(tabId);  
            if (page) {  
                var multipage = Main_GetMainMultiPage();  
                multipage.get_pageViews().remove(page);  
            }  
 
            if (seltab != null)  
                seltab.select();  
        }  
 
        function CheckTab(tabId) {  
            var ifrm = top.frames[0];  
            if (ifrm) {  
                alert(ifrm.location);  
            }  
            else {  
                alert(tabId + ' not found');  
            }  
        }  
        </script> 
    </telerik:RadScriptBlock>      
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <div> 
        <asp:Button id="AddTabButton" runat="server" OnClientClick="ShowTab('New Tab', '123','Test'); return false;" Text="Add Tab" /> 
        <asp:Button id="CloseTabButton" runat="server" OnClientClick="CloseTab('123'); return false;" Text="Close Tab" /> 
        <asp:Button id="CheckTabButton" runat="server" OnClientClick="CheckTab('123'); return false;" Text="Check Tab" /> 
    </div> 
    <div style="padding-top: 25px;">  
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1">  
            <Tabs> 
                <telerik:RadTab runat="server" Text="Default Tab">  
                </telerik:RadTab> 
            </Tabs> 
        </telerik:RadTabStrip> 
      
        <telerik:RadMultiPage ID="RadMultiPage1" Runat="server">  
            <telerik:RadPageView ID="RadPageView1" runat="server">  
                Default Page View (static)  
            </telerik:RadPageView> 
        </telerik:RadMultiPage> 
    </div> 
    </form> 
</body> 
</html> 
 


Any help and/or work-arounds are appreciated.
Scott R
Top achievements
Rank 1
 answered on 10 Oct 2008
1 answer
54 views
hi,

I want to clarify something, whenever I enter 3 consecutive underscore( ___ ) in the radeditor, upon displaying the item, the 3 underscore is changed into a long line, is this a behavior of the radeditor?

Thanks,
Jhobs
Rumen
Telerik team
 answered on 10 Oct 2008
1 answer
137 views
Hi,

    We are trying to sort Rad grid column which is date in format (mm/dd/yyyy)
We used Allow Sorting and Sorted Expression property of Grid,But it's working fine only for varchar not for date.So tell me how to solve this problem?

    Can It's posible to add one more column for date it will be visible false & when I click on my date column then sorting work according to my visible false column?

Please tell me correct way?

Thanks
Dimo
Telerik team
 answered on 10 Oct 2008
1 answer
54 views
Hi,

I'm having some problems with the radgrid-control.
When I apply a filter on the first page, everything works fine.
If I filter on the second page, I'm getting the following error:

Specified argument was out of the range of valid values. Parameter name: value.

I'm binding the radgrid to an objectdatasource. The selectmethod of the datasource returns  a dataset.

Kind regards,
Gert
Sebastian
Telerik team
 answered on 10 Oct 2008
6 answers
279 views
I'm following the examples in the Telerik Trainer for the RadMenuOverview.tts and I can't see the "Skin" in the drowdown of the controls design view. 

I don't have the 'ASP.NET AJAX-Enabled Web Site' template so I used the 'ASP.NET Web Application' template in Visual Studio Team System 2008. The only thing difference is supposed to be the 'asp:ScriptManager' is added to the Default.aspx. At least that is all that was mentioned in the two training vids I have seen. So I added it.

I noticed the path in the properties of the RadMenu1 of 'SkinsPath' and that was a default setting of '~/RadControls/Menu/Skins'. So I made that path in my project and placed the 'Skins' in there that came with the Telerik install '..\Telerik\RadControls for ASPNET AJAX Q2 2008\Skins'. Still I don't see the skins.

Please post any thoughts that you think might help me see the skins in the design view of the RadMenu.

Thank  you
Daniel
Top achievements
Rank 1
 answered on 10 Oct 2008
1 answer
59 views
I believe there is an incompatibility here.  The below code does not work, yet if I remove the RadAjaxPanel, it works fine.  Code below.  Any suggestions would be appreciated since the entire site is RadAjax-enabled.

<body> 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">  
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> 
    <div> 
        <asp:MediaPlayer Visible="false" ID="_mediaPlayer" runat="server" AutoUpgrade="true" Width="720" Height="400"  ></asp:MediaPlayer> 
    </div> 
    </telerik:RadAjaxPanel> 
    </form> 
</body> 
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        string path = System.Configuration.ConfigurationManager.AppSettings["SilverLightMovieLocation"] + "/Doe, Oct. 5, 2008";  
        System.IO.DirectoryInfo gallery = new DirectoryInfo(Server.MapPath(path));  
        FileInfo[] movie = gallery.GetFiles("*.wmv");  
        if (movie.GetUpperBound(0) > -1)  
        {  
            _mediaPlayer.Visible = true;  
            _mediaPlayer.MediaSource = path + "/" + movie[0].Name;  
            _mediaPlayer.AutoPlay = true;  
        }  
    } 
Sebastian
Telerik team
 answered on 10 Oct 2008
1 answer
63 views
I'm dinamically populating my Grid, without using DataSource object.
When my query returns more then 100,000 entries I receive a timeout error.
How can i increase performance on radGrid dynamic?
Vlad
Telerik team
 answered on 10 Oct 2008
1 answer
236 views

I need to create dock dynamically on page_Init, I have some error on aspx page which i mentioned with red color.Also do i need to change code in aspx.cs page



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="docking.aspx.cs" Inherits="docking" %>
<%@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<%--<%@ register tagprefix="qsf" tagname="Header" src="~/Common/Header.ascx" %>
<%@ register tagprefix="qsf" tagname="HeadTag" src="~/Common/HeadTag.ascx" %>
<%@ register tagprefix="qsf" tagname="Footer" src="~/Common/Footer.ascx" %>--%>

<!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">
   <%--  <qsf:headtag id="Headtag1" runat="server" />--%>
    <!--[if lte IE 6]>
    <style type="text/css">
    .raddockzone{height:200px}
    </style>
    <![endif]-->

</head>
<body>

  <form id="Form1" method="post" runat="server">
        <%--<qsf:header id="Header1" runat="server" navigationlanguage="c#" />--%>
        <asp:scriptmanager id="ScriptManager" runat="server" />
        <div class="module">
            <%--Select Module: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--%>
            <%-- <br/>Select Docking Zone:
            <asp:dropdownlist id="DropDownZone" runat="server" datasource="<%#GetZones() %>"
                datatextfield="ID" datavaluefield="ClientID" width="150">
            </asp:dropdownlist>--%>

            <asp:button runat="server"  id="ButtonAddDock" text="Add Dock"
                onclick="ButtonAddDock_Click"  />
                <asp:button runat="server"  id="loadDefaultDock" text="Load Default Dock"
                 onclick="loadDefaultDock_Click"
                  />
        </div>
        <br/>
        <telerik:raddocklayout runat="server" id="RadDockLayout1"
          onsavedocklayout="RadDockLayout1_SaveDockLayout"
            onloaddocklayout="RadDockLayout1_LoadDockLayout">
            <telerik:raddockzone runat="server" id="RadDockZone1" width="300" MinHeight="200" style="float:left;margin-right:15px;background: #f5f4e8;">
            </telerik:raddockzone>
            <telerik:raddockzone runat="server" id="RadDockZone2" width="300" MinHeight="200" style="background: #d5f0fa;float:left;">
            </telerik: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="UpdatePanel1">
                   <triggers>
                        <asp:asyncpostbacktrigger controlid="ButtonAddDock" eventname="Click" />
                   </triggers>
                   </asp:updatepanel>
                    <asp:updatepanel runat="server" id="UpdatePanel2">
                   <triggers>
                        <asp:asyncpostbacktrigger controlid="loadDefaultDock" eventname="Click" />
                   </triggers>
                   </asp:updatepanel>
                 <asp:updatepanel runat="server" id="UpdatePanel3">
                   <triggers>
                        <asp:asyncpostbacktrigger controlid="loadDefaultDock" eventname="Page_Init" />
                   </triggers>
                   </asp:updatepanel>

            </div>
        </telerik:raddocklayout>
 
      <%--  <qsf:footer runat="server" id="Footer1" showcodeviewer="true" />--%>

    </form>
</body>
</html>






This is my code



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
using System.Collections.Generic;
using SocialTerrain.Web.Lob;
using SocialTerrain.Web.Lob.Entity;
using System.Web.Script.Serialization;
using System.Data.SqlClient;
using SocialTerrain.Web.Dal;
using System.Xml.Serialization;
using System.IO;

 

public partial class docking : System.Web.UI.Page
{
    STDocksMasterCollection stDocksMasterCollectionObj = new STDocksMasterCollection();
    STDocksMaster stDocksMasterObj = new STDocksMaster();
    STDocksMasterRoot stDocksMasterRootObj = new STDocksMasterRoot();
   

    private List<DockState> CurrentDockStates
    {
        get
        {
            //Store the info about the added docks in the session. For real life
            // applications we recommend using database or other storage medium
            // for persisting this information.

            List<DockState> _currentDockStates = new List<DockState>();

           _currentDockStates = (List<DockState>)Session["DockStates"];
            if (Object.Equals(_currentDockStates, null))
            {
                _currentDockStates = new List<DockState>();
               Session["DockStates"] = _currentDockStates;
            }
         
            return _currentDockStates;
        
        }
        set
        {
            Session["DockStates"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //DroptDownWidget.Visible = false;

   
      
   }
    

        protected void Page_Init(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                Session["UserId"] = 62;
                int userId = int.Parse(Session["UserId"].ToString());
                STDocksMaster sTDocksMasterobj = stDocksMasterRootObj.GetDockState(userId);
                string dbDockState = sTDocksMasterobj.DocksState;
                if (dbDockState != null)
                {
                    object obj = null;
                    XmlSerializer xs = new XmlSerializer(typeof(List<DockState>));
                    obj = xs.Deserialize(new StringReader(dbDockState));
                    Session["DockStates"] = (List<DockState>)obj;
                }
               int available= stDocksMasterRootObj.CheckDocksUserAvailable(userId);
              if (sTDocksMasterobj.Status == false && Session["Status"] == null && available==1)
                {
                    CreateDynamicDock();
                    Session["Status"] = 1;
                }
            }
            //Recreate the docks in order to ensure their proper operation
            for (int i = 0; i < CurrentDockStates.Count; i++)
            {
                if (CurrentDockStates[i].Closed == false)
                {
                    RadDock dock = 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).
                    RadDockLayout1.Controls.Add(dock);
                    //We want to save the dock state every time a dock is moved.
                    CreateSaveStateTrigger(dock);
                    //Load the selected widget
                    LoadWidget(dock);
                }
            }
        }

        protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
        {
            //Populate the event args with the state information. The RadDockLayout control
            // will automatically move the docks according that information.
            foreach (DockState state in CurrentDockStates)
            {
                e.Positions[state.UniqueName] = state.DockZoneID;
                e.Indices[state.UniqueName] = state.Index;
            }
        }

        protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
        {
            //Save the dock state in the session. This will enable us
            // to recreate the dock in the next Page_Init.
            Session["UserId"] = 62;
            int userId = int.Parse(Session["UserId"].ToString());
            //stDocksMasterRootObj.DeleteDocksUser(userId);
            XmlSerializer ser = new XmlSerializer(typeof(List<DockState>));
            System.IO.StringWriter writer = new System.IO.StringWriter();
            ser.Serialize(writer, this.RadDockLayout1.GetRegisteredDocksState());
            string vv = writer.ToString();
            stDocksMasterRootObj.InsertDocksUser(userId, vv);
            STDocksMaster sTDocksMasterobj = stDocksMasterRootObj.GetDockState(userId);
            string dbDockState = sTDocksMasterobj.DocksState;
            object obj = null;
            XmlSerializer xs = new XmlSerializer(typeof(List<DockState>));
            obj = xs.Deserialize(new StringReader(dbDockState));
            Session["DockStates"] = (List<DockState>)obj;
           //// CurrentDockStates = (List<DockState>)Session["DockStates"];

        }

     

        private RadDock CreateRadDockFromState(DockState state)
        {
            RadDock dock = new RadDock();
            dock.ID = string.Format("RadDock{0}", state.UniqueName);
            dock.ApplyState(state);
            dock.Command += new DockCommandEventHandler(dock_Command);
            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());

            return dock;
        }

        private RadDock CreateRadDock()
        {
          
            int docksCount = CurrentDockStates.Count;
         
            RadDock dock = new RadDock();
            dock.UniqueName = Guid.NewGuid().ToString();
            dock.ID = string.Format("RadDock{0}", dock.UniqueName);

            dock.Title = "";
          
            dock.Text = string.Format("Added at {0}", DateTime.Now);
            dock.Width = Unit.Pixel(300);
            dock.CssClass="margin-bottom:3px !important";
           // stDocksMasterRootObj.InsertDocksMaster(dock.UniqueName, true);

            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());
            dock.Command += new DockCommandEventHandler(dock_Command);
          
            return dock;
        }

        void dock_Command(object sender, DockCommandEventArgs e)
        {
            if (e.Command.Name == "Close")
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1,this.GetType(),"RemoveDock",
                    string.Format(@"function _removeDock() {{
    Sys.Application.remove_load(_removeDock);
    $find('{0}').undock();
    $get('{1}').appendChild($get('{0}'));
    $find('{0}').doPostBack('DockPositionChanged');
}};
Sys.Application.add_load(_removeDock);", ((RadDock)sender).ClientID, UpdatePanel1.ClientID),
                true);

            }
        }

        private void CreateSaveStateTrigger(RadDock dock)
        {
            //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;

            AsyncPostBackTrigger saveStateTrigger = new AsyncPostBackTrigger();
            saveStateTrigger.ControlID = dock.ID;
            saveStateTrigger.EventName = "DockPositionChanged";
            UpdatePanel1.Triggers.Add(saveStateTrigger);

            saveStateTrigger = new AsyncPostBackTrigger();
            saveStateTrigger.ControlID = dock.ID;
            saveStateTrigger.EventName = "Command";
            UpdatePanel1.Triggers.Add(saveStateTrigger);
        }

        private void LoadWidget(RadDock dock)
        {
            if (string.IsNullOrEmpty(dock.Tag))
            {
                return;
            }
            Control widget = LoadControl(dock.Tag);
            dock.ContentContainer.Controls.Add(widget);
        }

        protected void ButtonAddDock_Click(object sender, EventArgs e)
        {
            string _zone;
            RadDock dock = CreateRadDock();
            //In order to optimize the execution speed we are adding the dock to a
            // hidden update panel and then register a script which will move it
            // to RadDockZone1 after the AJAX request completes. If you want to
            // dock the control in other zone, modify the script according your needs.
          

                UpdatePanel1.ContentTemplateContainer.Controls.Add(dock);

                int countzone1 = RadDockZone1.Docks.Count;
                int countzone2 = RadDockZone2.Docks.Count;
                if (countzone1 <= countzone2)
                {
                    _zone = "RadDockZone1";
                }
                else
                    _zone = "RadDockZone2";

            ScriptManager.RegisterStartupScript(
            dock,
            this.GetType(),
            "AddDock",
            string.Format(@"function _addDock() {{
                          Sys.Application.remove_load(_addDock);
                             $find('{1}').dock($find('{0}'));
                                $find('{0}').doPostBack('DockPositionChanged');}};
                          Sys.Application.add_load(_addDock);", dock.ClientID, _zone),
            true);

            //Right now the RadDock control is not docked. When we try to save its state
            // later, the DockZoneID will be empty. To workaround this problem we will
            // set the AutoPostBack property of the RadDock control to true and will
            // attach an AsyncPostBackTrigger for the DockPositionChanged client-side
            // event. This will initiate second AJAX request in order to save the state
            // AFTER the dock was docked in RadDockZone1.
            CreateSaveStateTrigger(dock);

            //Load the selected widget in the RadDock control
            //DroptDownWidget.Visible = true;
            dock.Tag = "Members/UserControl/DockUserControl.ascx";
           LoadWidget(dock);

        }

        protected void CreateDynamicDock()
        {

            RadDockZone1.Docks.Clear();
            RadDockZone2.Docks.Clear();
            STDocksMasterRoot sTDocksMasterRootObj = new STDocksMasterRoot();
            STDocksMasterCollection sTDocksMasterCollectionObj = sTDocksMasterRootObj.GetAllDocksName();
            string _zone;

            foreach (STDocksMaster dockName in sTDocksMasterCollectionObj)
            {
                RadDock dock = CreateRadDock();
                //In order to optimize the execution speed we are adding the dock to a
                // hidden update panel and then register a script which will move it
                // to RadDockZone1 after the AJAX request completes. If you want to
                // dock the control in other zone, modify the script according your needs.

                UpdatePanel3.ContentTemplateContainer.Controls.Add(dock);

                if (ViewState["i"] == null)
                {
                    ViewState["i"] = 1;
                    _zone = "RadDockZone1";
                }
                else
                {
                    ViewState.Remove("i");
                    _zone = "RadDockZone2";
                }
              

                ScriptManager.RegisterStartupScript(

              dock,
              this.GetType(),
              "AddDock" + dock.ClientID,
              string.Format(@"function _addDock() {{
                          Sys.Application.remove_load(_addDock);
                             $find('{1}').dock($find('{0}'));
                                $find('{0}').doPostBack('DockPositionChanged');}};
                          Sys.Application.add_load(_addDock);", dock.ClientID, _zone),
              true);

 

                //Right now the RadDock control is not docked. When we try to save its state
                // later, the DockZoneID will be empty. To workaround this problem we will
                // set the AutoPostBack property of the RadDock control to true and will
                // attach an AsyncPostBackTrigger for the DockPositionChanged client-side
                // event. This will initiate second AJAX request in order to save the state
                // AFTER the dock was docked in RadDockZone1.
                CreateSaveStateTrigger(dock);
                if (dockName.DocksName == "Blogs")
                {
                    dock.Tag = "Members/UserControl/BlogUserControl.ascx";
                    dock.Title = "Blogs";
                }
                if (dockName.DocksName == "Videos")
                {
                    dock.Tag = "Members/UserControl/VideoUserControl.ascx";
                    dock.Title = "Videos";
                }
                //Load the selected widget in the RadDock control
                //DroptDownWidget.Visible = true;

                LoadWidget(dock);

            }
        }

        protected void loadDefaultDock_Click(object sender, EventArgs e)
        {
            Session["UserId"] = 62;
            int userId = int.Parse(Session["UserId"].ToString());
            stDocksMasterRootObj.DeleteDocksUser(userId);
            //int countzone1 = RadDockZone1.Docks.Count;
            //int countzone2 = RadDockZone2.Docks.Count;
            //for (int i = countzone1 - 1; i > -1; i--)
            //{
            //    RadDockZone1.Docks.Remove(RadDockZone1.Docks[i]);
            //}
            //for (int j = countzone2 - 1; j > -1; j--)
            //{
            //    RadDockZone2.Docks.Remove(RadDockZone2.Docks[j]);
            //}
            RadDockZone1.Docks.Clear();
            RadDockZone2.Docks.Clear();
            STDocksMasterRoot sTDocksMasterRootObj = new STDocksMasterRoot();
            STDocksMasterCollection sTDocksMasterCollectionObj = sTDocksMasterRootObj.GetAllDocksName();
            string _zone;

            foreach (STDocksMaster dockName in sTDocksMasterCollectionObj)
            {
                RadDock dock = CreateRadDock();
                //In order to optimize the execution speed we are adding the dock to a
                // hidden update panel and then register a script which will move it
                // to RadDockZone1 after the AJAX request completes. If you want to
                // dock the control in other zone, modify the script according your needs.

                UpdatePanel2.ContentTemplateContainer.Controls.Add(dock);

                if (ViewState["i"] == null)
                {
                     ViewState["i"] = 1;
                    _zone = "RadDockZone1";
                }
                else
                {
                     ViewState.Remove("i");
                    _zone = "RadDockZone2";
                }
           
                ScriptManager.RegisterStartupScript(
                     //UpdatePanel1,
                     //typeof(RadDock),
                     //"DockIntoZone" + dock.ClientID,
              dock,
              this.GetType(),
              "AddDock" + dock.ClientID,
              string.Format(@"function _addDock() {{
                          Sys.Application.remove_load(_addDock);
                             $find('{1}').dock($find('{0}'));
                                $find('{0}').doPostBack('DockPositionChanged');}};
                          Sys.Application.add_load(_addDock);", dock.ClientID, _zone),
              true);

                //Right now the RadDock control is not docked. When we try to save its state
                // later, the DockZoneID will be empty. To workaround this problem we will
                // set the AutoPostBack property of the RadDock control to true and will
                // attach an AsyncPostBackTrigger for the DockPositionChanged client-side
                // event. This will initiate second AJAX request in order to save the state
                // AFTER the dock was docked in RadDockZone1.
                CreateSaveStateTrigger(dock);
                if (dockName.DocksName == "Blogs")
                {
                    dock.Tag = "Members/UserControl/BlogUserControl.ascx";
                    dock.Title = "Blogs";
                }
                if (dockName.DocksName == "Videos")
                {
                    dock.Tag = "Members/UserControl/VideoUserControl.ascx";
                    dock.Title = "Videos";
                }
                //Load the selected widget in the RadDock control
                //DroptDownWidget.Visible = true;

                LoadWidget(dock);

            }
        }
       
}

 

Obi-Wan Kenobi
Top achievements
Rank 1
 answered on 10 Oct 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?