How can we use .aspx page (with querystring) inside raddoc?

9 posts, 1 answers
  1. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 27 Nov 2010 Link to this post

    Hi All,

           How can we use .aspx page (with querystring) inside raddoc?
    I am referring foll. example - "http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx"

    Please help..Waiting for your reply
  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 30 Nov 2010 Link to this post

    Hi Abhi,

    An <iframe/> can be added to the RadDock's content container, and then add a "src" attribute to <iframe/> itself with the desired page. For your convenience I have attached a simple project showing this.

    Best wishes,
    Pero
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 01 Dec 2010 Link to this post

    Thank you Pero,
                   Above code is working fine.
    But I am using multiple Raddocs in a page under a RadLayout.

    AND I have to save the state of raddocs in database and retrieve the saved state.

    waiting for reply...
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 07 Dec 2010 Link to this post

    Hello Abhi,

    We have two articles in our Code Library that show how to save the DockState of dynamically created docks in DataBase. Here are links to them:
    Please download the source code, and carefully examine it to see how the state is saved and loaded in/from the DataBase.

    Regards,
    Pero
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 08 Dec 2010 Link to this post

    Hello 
          
    I am using <iframe> in rad grid and saved the state in database like as follows-

    {"UniqueName":"RadDock1","DockZoneID":"RadDockZone1","Width":"300px","Height":"","ExpandedHeight":"0","Top":"0px","Left":"0px","Resizable":"False","Closed":"False","Collapsed":"False","Pinned":"False","Title":"RadDock-Title","Text":"","Tag":null,"Index":"0"}|{"UniqueName":"RadDock2","DockZoneID":"RadDockZone2","Width":"300px","Height":"","ExpandedHeight":"0","Top":"0px","Left":"0px","Resizable":"False","Closed":"False","Collapsed":"False","Pinned":"False","Title":"RadDock-Title","Text":"","Tag":null,"Index":"0"}|{"UniqueName":"RadDock3","DockZoneID":"RadDockZone3","Width":"300px","Height":"","ExpandedHeight":"0","Top":"0px","Left":"0px","Resizable":"False","Closed":"False","Collapsed":"False","Pinned":"False","Title":"RadDock-Title","Text":"","Tag":null,"Index":"0"}|

    I know the above saved state is not correct.
    Why <Iframe> url is'nt saved in state?
    can you send me the code of saving state of Raddoc (which is using <iframe> not usercontrol) in database?

    Please help me its veryyyyyyyyyyyyyy urgent !!!!

  7. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 08 Dec 2010 Link to this post

    Hi Abhi,

    Could you please make sure the URL set as a src to the <iframe/> is set to the RadDock's Tag property? I have modified the MyPortal demo to use <iframe/>s instead of RadDocks. Please find it attached to the thread.

    All the best,
    Pero
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 09 Dec 2010 Link to this post

    Dear Pero,
                  I think raddocks tag property is set because Iframe's src is set successfully to url.
    (IframeDock1.Attributes.Add("src", RadDock1.ResolveUrl(dock.Tag));)

    Please refer following code.

    Widget.aspx page -
    <html>
    <head>
        <base target="_self"></base>
        <title>a </title>
    </head>
    <body>
        <form id="calHome" name="calHome" action="" method="post" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
         
        <div id="myDiv_CRM" style="width: 100%;">
            <table border="2" width="100%">
                <tr>
                    <td id="listOfWidgets">
                        <table style="width: 100%">
                            <tr>
                                <td>
                                    <asp:Label ID="lblError" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 140px">
                                    Select Module:
                                </td>
                                <td style="width: 140px">
                                    <telerik:RadComboBox name="drpItems" ID="drpItems"class="drpbx" AutoPostBack="true"
                                        runat="server">
                                    </telerik:RadComboBox>
                                </td>
                                <td>
                                </td>
                                <td>                               
                                    <asp:Button runat="server" ID="btnSaveState" Text="SAVE STATE" OnClick="btnSaveState_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Select Docking Zone:
                                </td>
                                <td>
                                    <telerik:RadComboBox name="DropDownZone" ID="DropDownZone"class="drpbx" DataSource="<%#GetZones() %>"
                                        DataTextField="ID" DataValueField="ClientID" runat="server">
                                    </telerik:RadComboBox>
                                </td>
                                <td>
                                    <asp:Button runat="server" ID="ButtonAddDock" Text="Add Dock (AJAX)" OnClick="ButtonAddDock_Click" />
                                </td>
                                <td>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td id="HomePage">
                        <asp:UpdatePanel runat="server" ID="UpdatePanel2"ChildrenAsTriggers="false" UpdateMode="Conditional">
                            <ContentTemplate>
                                <br />
                                <telerik:RadDockLayout runat="server" ID="RadDockLayout1"OnSaveDockLayout="RadDockLayout1_SaveDockLayout"
                                    OnLoadDockLayout="RadDockLayout1_LoadDockLayout">
                                    <telerik:RadDockZone runat="server" ID="RadDockZone1"Width="300" MinHeight="300"
                                        Style="float: left; margin-right: 15px">
                                        <telerik:RadDock ID="RadDock1" runat="server"Title="RadDock-Title" Width="300px">
                                            <ContentTemplate>
                                                <iframe id="IframeDock1" runat="server"style="width: 300px; height: 300px"></iframe>
                                            </ContentTemplate>
                                        </telerik:RadDock>
                                    </telerik:RadDockZone>
                                    <telerik:RadDockZone runat="server" ID="RadDockZone2"Width="300" MinHeight="300"
                                        Style="float: left; margin-right: 15px; background: #f5f4e8;">
                                        <telerik:RadDock ID="RadDock2" runat="server"Title="RadDock-Title" Width="300px">
                                            <ContentTemplate>
                                                <iframe id="IframeDock2" runat="server"style="width: 300px; height: 300px"></iframe>
                                            </ContentTemplate>
                                        </telerik:RadDock>
                                    </telerik:RadDockZone>
                                    <telerik:RadDockZone runat="server" ID="RadDockZone3"Width="300" MinHeight="300"
                                        Style="background: #d5f0fa; float: left;">
                                        <telerik:RadDock ID="RadDock3" runat="server"Title="RadDock-Title" Width="300px">
                                            <ContentTemplate>
                                                <iframe id="IframeDock3" runat="server"style="width: 300px; height: 300px"></iframe>
                                            </ContentTemplate>
                                        </telerik:RadDock>
                                    </telerik:RadDockZone>
                                </telerik:RadDockLayout>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="ButtonAddDock"EventName="Click" />
                            </Triggers>
                        </asp:UpdatePanel>
                        <div style="width: 0px; height: 0px; overflow: hidden; position: absolute; left: -10000px;">
                            Hidden UpdatePanel, which is used to help with saving state when minimizing, moving
                            and closing docks. This way the docks state is saved faster (no need to update the
                            docking zones).
                            <asp:UpdatePanel runat="server" ID="UpdatePanel1">
                            </asp:UpdatePanel>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        </form>
    </body>
    </html>


    Widget.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using System.Collections;
    using System.Data;
    using System.Configuration;
    using System.Text;
     
    namespace crm.Organisation.Employee
    {
        public partial class DesignHomeUsingWidget : System.Web.UI.Page
        {
            private int _count = 0;
            string strSQL = "";
            string dataText = "";
            string dataValue = "";
            private bool _dockStateCleared = false;
            private List<DockState> CurrentDockStates
            {
                get
                {
                    List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesMyPortal"];
                    if (Object.Equals(_currentDockStates, null))
                    {
                        _currentDockStates = new List<DockState>();
                        Session["CurrentDockStatesMyPortal"] = _currentDockStates;
                    }
                    return _currentDockStates;
                }
                set
                {
                    Session["CurrentDockStatesMyPortal"] = value;
                }
            }
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    DropDownZone.DataBind();
                    if (Session["userid"] != null)
                    
                        string strSQL = "SQL Query here.";
                        drpItems.Items.Clear();
                        drpItems.DataSource = GetDataSet(strSQL);
                        drpItems.DataTextField = "name";
                        drpItems.DataValueField = "url"//bind widget user control URL here
     
                        drpItems.DataBind();
                    }
                }
            }
            public ArrayList GetZones()
            {
                ArrayList zones = new ArrayList();
                zones.Add(RadDockZone1);
                zones.Add(RadDockZone2);
                zones.Add(RadDockZone3);
                return zones;
            }
            protected void Page_Init(object sender, EventArgs e)
            {
            }
            protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
            {
                 
                System.Web.Script.Serialization.JavaScriptSerializer serializer = newSystem.Web.Script.Serialization.JavaScriptSerializer();
                 string dockState = "";
                try
                {
                    dockState = executeSQLRTN("select State from UsersWidgetState where userid = '"+ Session["userid"].ToString() + "'");
                    //executeSQLRTN returns string
                }
                catch
                {
                }
     
                string[] currentDockStates = dockState.Split('|');
                foreach (string stringState in currentDockStates)
                {
                    if (stringState.Trim() != string.Empty)
                    {
                        DockState state = serializer.Deserialize<DockState>(stringState);
                        e.Positions[state.UniqueName] = state.DockZoneID;
                        e.Indices[state.UniqueName] = state.Index;
                    }
                }
            }
            protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
            {
                 
                string dockState;
                System.Web.Script.Serialization.JavaScriptSerializer serializer = newSystem.Web.Script.Serialization.JavaScriptSerializer();
                List<DockState> stateList = RadDockLayout1.GetRegisteredDocksState();
                StringBuilder serializedList = new StringBuilder();
                int i = 0;
                while (i < stateList.Count)
                {
                    serializedList.Append(serializer.Serialize(stateList[i]));
                    serializedList.Append("|");
                    i++;
                }
                dockState = serializedList.ToString();
                if (dockState.Trim() != String.Empty)
                {
                    try
                    {
                        executeSQLRTN("update UsersWidgetState set state = '" + dockState + "' where userid = '" + Session["userid"].ToString() + "'");
                    }
                    catch
                    {
                    }
                }
            }
            private RadDock CreateRadDockFromState(string stringState)
            {
                System.Web.Script.Serialization.JavaScriptSerializer serializer = newSystem.Web.Script.Serialization.JavaScriptSerializer();
                DockState state = serializer.Deserialize<DockState>(stringState);
                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;
            }
            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 RadDock CreateRadDock()
            {
                RadDock dock = new RadDock();
                dock.UniqueName = Guid.NewGuid().ToString();
                dock.ID = string.Format("RadDock{0}", dock.UniqueName);
                dock.Title = "Dock";
                dock.Text = string.Format("Added at {0}", DateTime.Now);
                dock.Width = Unit.Pixel(300);
     
                dock.Commands.Add(new DockCloseCommand());
                dock.Commands.Add(new DockExpandCollapseCommand());
                dock.Command += new DockCommandEventHandler(dock_Command);
     
                return dock;
            }
            private void CreateSaveStateTrigger(RadDock dock)
            {
                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;
                }
                if (RadDockZone1.ID == DropDownZone.SelectedItem.Text)
                {
                    IframeDock1.Attributes.Add("src", RadDock1.ResolveUrl(dock.Tag));
                }
                else if (RadDockZone2.ID == DropDownZone.SelectedItem.Text)
                {
                    IframeDock2.Attributes.Add("src", RadDock2.ResolveUrl(dock.Tag));
                }
                else if (RadDockZone3.ID == DropDownZone.SelectedItem.Text)
                {
                    IframeDock3.Attributes.Add("src", RadDock3.ResolveUrl(dock.Tag));
                }
            }
            protected void ButtonAddDock_Click(object sender, EventArgs e)
            {
                RadDock dock = CreateRadDock();
                RadDockZone dz = (RadDockZone)FindControl(DropDownZone.SelectedItem.Text);
                dz.Controls.Add(dock);
                CreateSaveStateTrigger(dock);
                dock.Tag = drpItems.SelectedValue;
                LoadWidget(dock);
            }
            protected void btnSaveState_Click(object sender, EventArgs e)
            {
                SaveState();
            }
            protected void SaveState()
            {
                SQlColinfo.Common MyCOM = new SQlColinfo.Common();
                string dockState;
                System.Web.Script.Serialization.JavaScriptSerializer serializer = newSystem.Web.Script.Serialization.JavaScriptSerializer();
                List<DockState> stateList = RadDockLayout1.GetRegisteredDocksState();
                StringBuilder serializedList = new StringBuilder();
                int i = 0;
                while (i < stateList.Count)
                {
                    serializedList.Append(serializer.Serialize(stateList[i]));
                    serializedList.Append("|");
                    i++;
                }
                dockState = serializedList.ToString();
                if (dockState.Trim() != String.Empty)
                {
                    try
                    {
                        if (MyCOM.ExecuteSQL("insert into UsersWidgetState (userid,state) values ('" + Session["userid"].ToString() + "','" + dockState + "')"))
                        {
                            lblError.Text = "State Saved Successfully!";
                        }
                        else
                        {
                            lblError.Text = "Not saved!";
                        }
                    }
                    catch (Exception e)
                    {
                        lblError.Text = "Not saved!" + e.Message;
                    }
                }
                  
            }
        }
     
    }


    Waiting for your valuable reply...!!!!!!
  9. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 09 Dec 2010 Link to this post

    Hello Abhi,

    I examined the code and everything seems to be configured correctly. I modified the sample code from my previous reply to save the state in DB. Everything is working correctly, and you can model your application based on it.

    All the best,
    Pero
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  10. Abhi Shinde
    Abhi Shinde avatar
    56 posts
    Member since:
    May 2010

    Posted 10 Dec 2010 Link to this post

    Perfect !!!
    thanksssss PERO, 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017