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

How to insert dock state in sqlserver

7 Answers 172 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 24 Jan 2009, 03:09 PM
Dear sir,
             I have create one aspx page. The page name is Home.aspx. But i am not create dock at runtime already i created my design page.Now i have 9 dockcontrol in my page.if user has change the dock control at runtime it was maintain state after that he will come back same state maintain any machine.Please help me sir....

Thanks and regards

Raja


I have upload my aspx page and aspx.cs page in this mail.

aspx page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>

<%@ Register Src="uclContent.ascx" TagName="uclContent" TagPrefix="uc1" %>
<%@ Register Src="uclEmail.ascx" TagName="uclEmail" TagPrefix="uc2" %>
<%@ Register Src="uclTimedate.ascx" TagName="uclTimedate" TagPrefix="uc3" %>
<%@ Register Src="uclAnnouncement.ascx" TagName="uclAnnouncement" TagPrefix="uc4" %>
<%@ Register Src="uclCustomerservice.ascx" TagName="uclCustomerservice" TagPrefix="uc5" %>
<%@ Register Src="uclWeather.ascx" TagName="uclWeather" TagPrefix="uc6" %>
<%@ Register Src="uclLinks.ascx" TagName="uclLinks" TagPrefix="uc7" %>
<%@ Register Src="uclNews.ascx" TagName="uclNews" TagPrefix="uc8" %>
<%@ Register Src="uclTechnicalsupport.ascx" TagName="uclTechnicalsupport" TagPrefix="uc9" %>
<%@ 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>Home.........:::</title>
</head>

<script type="text/javascript">
function frmsubmit()
{
    document.form1.submit();
    window.close();     
        
}
window.onunload = function()
{
        document.forms['frmHome'].submit();        
        window.close();        
}

</script>

<body>
    <form id="frmHome" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            &nbsp;</div>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server" EnableViewState="false"
            OnLoadDockLayout="RadDockLayout1_LoadDockLayout" OnSaveDockLayout="RadDockLayout1_SaveDockLayout"
            StoreLayoutInViewState="false">
            <table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td style="width: 100px">
                        <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="800px" Width="380px">
                            <telerik:RadDock ID="RadDock1" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc1:uclContent ID="UclContent1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                            <telerik:RadDock ID="RadDock4" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc4:uclAnnouncement ID="UclAnnouncement1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                            <telerik:RadDock ID="RadDock7" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc7:uclLinks ID="UclLinks1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                        </telerik:RadDockZone>
                    </td>
                    <td style="width: 100px">
                        <telerik:RadDockZone ID="RadDockZone2" runat="server" Height="800px" Width="300px">
                            <telerik:RadDock ID="RadDock2" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc2:uclEmail ID="UclEmail1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                            <telerik:RadDock ID="RadDock5" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc5:uclCustomerservice ID="UclCustomerservice1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                            <telerik:RadDock ID="RadDock8" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc8:uclNews ID="UclNews1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                        </telerik:RadDockZone>
                    </td>
                    <td style="width: 100px">
                        <telerik:RadDockZone ID="RadDockZone3" runat="server" Height="800px" Width="300px">
                            <telerik:RadDock ID="RadDock3" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc3:uclTimedate ID="UclTimedate1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                            <telerik:RadDock ID="RadDock6" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc6:uclWeather ID="UclWeather1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                            <telerik:RadDock ID="RadDock9" runat="server" Width="300px" DockHandle="Grip">
                                <ContentTemplate>
                                    <uc9:uclTechnicalsupport ID="UclTechnicalsupport1" runat="server" />
                                </ContentTemplate>
                            </telerik:RadDock>
                        </telerik:RadDockZone>
                    </td>
                </tr>
            </table>
        </telerik:RadDockLayout>
    </form>
</body>
</html>


aspx.cs.page

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Script.Serialization;
using System.Collections.Generic;
using System.Web.SessionState;
using Telerik.Web.UI;

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //Response.Write("<script language=javascript>alert('Yes')</script>");            
        }
    }
    protected void Page_Unload(object sender, EventArgs e)
    {

        //form1.Attributes.Add("onunload", "<script language=javascript>alert('Yes')</script>");
    }
   
    protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
    {
        // Store the positions in a cookie. Note, that if there are lots of dock objects on the page
        // the cookie length might become insufficient. In this case it would be better to use the
        // cookie to store a key from a database, where the positions will be actually stored.
        //
        // You can store the positions directly in a database and use the ID of the currently logged
        // user as a key to his personalized positions.
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        string serializedPositions = serializer.Serialize(e.Positions);
        string serializedIndices = serializer.Serialize(e.Indices);

        HttpCookie positionsCookie = new HttpCookie("DockLayout",
            serializer.Serialize(new string[] { serializedPositions, serializedIndices }));

        //Ensure that the cookie will not expire soon
        positionsCookie.Expires = DateTime.Now.AddYears(1);
        Response.Cookies.Add(positionsCookie);
    }

    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
        HttpCookie positionsCookie = Request.Cookies["DockLayout"];
        if (!Object.Equals(positionsCookie, null))
        {
            string serializedPositionsAndIndices = positionsCookie.Value;
            if (!string.IsNullOrEmpty(serializedPositionsAndIndices))
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string[] positionsAndIndices = serializer.Deserialize<string[]>(serializedPositionsAndIndices);

                e.Positions = serializer.Deserialize<Dictionary<string, string>>(positionsAndIndices[0]);
                e.Indices = serializer.Deserialize<Dictionary<string, int>>(positionsAndIndices[1]);
            }
        }
    }
   
    
 
    protected void ButtonAddDock_Click(object sender, EventArgs e)
    {

    }
    protected void lnkSave_Click(object sender, EventArgs e)
    {

    }
}





7 Answers, 1 is accepted

Sort by
0
Nikolay Raykov
Telerik team
answered on 27 Jan 2009, 08:49 AM
Hi Raja,

I am not exactly sure what you are trying to achieve. I created a test page with your code, moved some of the docks around and after reloading the page their state was preserved - everything works OK.

If you are trying to persist the state of RadDock controls to a SQL Server you could save the serialized data into a database instead of a cookie. You could use nvarchar for the field type but it is up to you to write your own database layer.

If this is not the case could you elaborate on your problem?

Kind regards,
Nikolay Raykov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Raja
Top achievements
Rank 1
answered on 27 Jan 2009, 10:04 AM
Dear sir,
            Thanks your prompt reply.During Drag and drop, i want to update the database with the current state of controls.

So that whenever user login i have to display the latest saved positions.

To achieve that where i have to write the code. I need an samples for this.


Thanks and Regards

A.Raja

                
0
Nikolay Raykov
Telerik team
answered on 30 Jan 2009, 09:48 AM
Hello Raja,

All you need to do to accomplish your scenario is to attach event handlers for the LoadDockLayout and SaveDockLayout events and implement the loading/saving mechanism to your database there. Then set the AutoPostBack property of all docks to true in order to make a postback whenever you change the position of a dock. You could ajaxify the postback to the server if you want as well.

Here is how the declaration of the docks would look like:

<telerik:RadDockLayout ID="RadDockLayout1" runat="server" 
        OnSaveDockLayout="RadDockLayout1_SaveDockLayout" 
        OnLoadDockLayout="RadDockLayout1_LoadDockLayout">  
        <telerik:RadDockZone ID="RadDockZone1" runat="server">  
            <telerik:RadDock ID="RadDock1" runat="server" Title="RadDock" AutoPostBack="true">  
                <ContentTemplate> 
                    RadDock 1  
                </ContentTemplate> 
            </telerik:RadDock> 
            <telerik:RadDock ID="RadDock2" runat="server" Title="RadDock" AutoPostBack="true">  
                <ContentTemplate> 
                    RadDock 2  
                </ContentTemplate> 
            </telerik:RadDock> 
        </telerik:RadDockZone> 
        <telerik:RadDockZone ID="RadDockZone2" runat="server"></telerik:RadDockZone> 
    </telerik:RadDockLayout> 

And the event handlers:

protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        //Query your database to load the persisted state of the docks.          
        //Populate the event args with the state information. The RadDockLayout control  
        // will automatically move the docks according that information.  
    }  
 
    protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        //Save the dock state in the database.  
    } 

Now you need to write your database query code and you would accomplish your scenario.

All the best,
Nikolay Raykov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Raja
Top achievements
Rank 1
answered on 30 Jan 2009, 01:07 PM
Thanks sir,

                  Sir one more request to you.I need tabstrip controls like igoogle 'Addnewtab' same like this.If i click this button it is load one more button.And i am unable to find "Telerik.Quickstart.dll" from telerick bin folder.can you give me that dll.

Thanks and regards

Raja
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 02 Feb 2009, 10:10 AM
You don't need "Telerik.Quickstart.dll" for your project, it is related to the examples provided by telerik.
To achieve a " igoogle 'Addnewtab' " You should use the RadTabStirp and on tab click you should add a new tab via server side api.
Please take a look at the links below, I hope that they will be helpful.
similar example:http://demos.telerik.com/aspnet-ajax/tabstrip/examples/serverside/addremovedisable/defaultcs.aspx
online documentation:http://www.telerik.com/help/aspnet-ajax/tab_tabclick.html
0
Raja
Top achievements
Rank 1
answered on 07 Feb 2009, 06:16 PM
Hi sir,
I have created one aspx page in my project.Here I have load bit value data from database table to bind in datagrid.So now i want to add checkbox inside datagrid instead of bitvalue data value.what should i do please help me sir and i have upload that pages and screenshot

aspx page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ElementLocation.aspx.cs" Inherits="ElementLocation" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table border="0" width="100%">
         <tr >
            <td align="left" >
              <a href="default.aspx" class="top1">Home</a>
           </td>
           <td align="right" >
              <a  href="Login.aspx" class="top1" >Logout</a>
           </td>
         </tr>
        </table>
        <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr class="pageTitle">
                <td align="Center" style="height: 50px">Element Location</td>
            </tr>
            <tr>
             <td class="normalTextBold" style="height: 20px; padding-right: 118px;padding-bottom:10px;">
                 <asp:GridView ID="gvElementLocation" runat="server">
                     
                 
                 </asp:GridView>
                 
            </td>
            </tr>
        </table>
        
    </div>
    </form>
</body>
</html>


aspx.cs.page

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ElementLocation : System.Web.UI.Page
{
    Reports rpt = new Reports();
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = rpt.ElementLocation();

        try
        {
            DataTable Dt = GetInversedDataTable(ds.Tables[0], "SourceLocationDesc", "ElementDesc", "Checked");
            //int colcount = Dt.Columns.Count;
            //for (int i = 0; i < colcount; i++)
            //{
            //    TemplateField tf -new TemplateField();    
            //}
            
            gvElementLocation.DataSource = Dt;
            gvElementLocation.DataBind();

        }
           
        catch (Exception oEx)
        {
            Tracing("ElementLocation", oEx);
            //return null;
        }
    }
    /// <summary>
    /// Gets a Inverted DataTable
    /// </summary>
    /// <param name="table">Provided DataTable</param>
    /// <param name="columnX">X Axis Column</param>
    /// <param name="columnY">Y Axis Column</param>
    /// <param name="columnZ">Z Axis Column (values)</param>
    /// <param name="columnsToIgnore">Whether to ignore some column, it must be
    /// provided here</param>
    /// <param name="nullValue">null Values to be filled</param>
    /// <returns>C# Pivot Table Method  - Felipe Sabino</returns>
    public static DataTable GetInversedDataTable(DataTable table, string SourceLocationID, string ElementID, string ElementLocationID)
    {
        //Create a DataTable to Return
        DataTable returnTable = new DataTable();

        if (SourceLocationID == "")
            SourceLocationID = table.Columns[0].ColumnName;

        //Add a Column at the beginning of the table
        returnTable.Columns.Add(ElementID);


        //Read all DISTINCT values from columnX Column in the provided DataTale
        List<string> SourceLocationIDValues = new List<string>();

        foreach (DataRow dr in table.Rows)
        {

            string SourceLocationIDTemp = dr[SourceLocationID].ToString();
            if (!SourceLocationIDValues.Contains(SourceLocationIDTemp))
            {
                //Read each row value, if it's different from others provided, add to
                //the list of values and creates a new Column with its value.
                SourceLocationIDValues.Add(SourceLocationIDTemp);
                returnTable.Columns.Add(SourceLocationIDTemp);
            }
        }
        
        //Verify if Y and Z Axis columns re provided
        if (ElementID != "" && ElementLocationID != "")
        {
            //Read DISTINCT Values for Y Axis Column
            List<string> ElementIDValues = new List<string>();

            foreach (DataRow dr in table.Rows)
            {
                if (!ElementIDValues.Contains(dr[ElementID].ToString()))
                    ElementIDValues.Add(dr[ElementID].ToString());
            }

            //Loop all Column Y Distinct Value
            foreach (string ElementIDValue in ElementIDValues)
            {
                //Creates a new Row
                DataRow drReturn = returnTable.NewRow();
                drReturn[0] = ElementIDValue;
                //foreach column Y value, The rows are selected distincted
                DataRow[] rows = table.Select(ElementID + "='" + ElementIDValue + "'");

                //Read each row to fill the DataTable
                foreach (DataRow dr in rows)
                {
                    string rowColumnTitle = dr[SourceLocationID].ToString();

                    //Read each column to fill the DataTable
                    foreach (DataColumn dc in returnTable.Columns)
                    {
                        if (dc.ColumnName == rowColumnTitle)
                        {
                            //If Sum of Values is True it try to perform a Sum
                            //If sum is not possible due to value types, the value
                            // displayed is the last one read
                            drReturn[rowColumnTitle] = dr[ElementLocationID];
                        }
                    }
                }

                returnTable.Rows.Add(drReturn);
            }

        }
        else
        {
            throw new Exception("The columns to perform inversion are not provided");
        }

        //if a nullValue is provided, fill the datable with it
        //if (nullValue != "")
        //{
        //    foreach (DataRow dr in returnTable.Rows)
        //    {
        //        foreach (DataColumn dc in returnTable.Columns)
        //        {
        //            if (dr[dc.ColumnName].ToString() == "")
        //                dr[dc.ColumnName] = nullValue;
        //        }
        //    }
        //}

        return returnTable;
    }
    public void Tracing(string ProcedureName, Exception oEx)
    {
        string strClassName = "SourceLocationList";
        Logfile oSqlLog = new Logfile(strClassName, ProcedureName, oEx);
    }
}




0
Raja
Top achievements
Rank 1
answered on 25 Mar 2009, 02:55 PM
Hi,
In .NET  Adrotator control there is a event AdCreated.
What is the  event in RadRotator  equivalent  to the above. 

Thanks and regards

Raja
Tags
Dock
Asked by
Raja
Top achievements
Rank 1
Answers by
Nikolay Raykov
Telerik team
Raja
Top achievements
Rank 1
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or