Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
251 views
Hello,
I may have some trouble about Dynamic Saving & Loading docks from MS SQL DATABASE.

Please Help Me!!!

This is my default.cs file!

is there any sample for "dynamic add" + "SAVE&LOAD" for us?

error message "serializer doesn't support 'Telerik.Web.UI.DockState'." 
 
using System;  
using System.Data;  
using System.Data.SqlClient;  
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 Telerik.Web.UI;  
using System.Text;  
 
public partial class index : System.Web.UI.Page  
{  
    protected string LoadUserData(string UserAccount)  
    {  
        SqlConnection conn = new SqlConnection("Data Source=(LOCAL);;Initial Catalog=BPMDB;User ID=sa;Password=*******");  
        conn.Open();  
 
        string SQLStr = "SELECT  [string] FROM [index_position] WHERE (id_user = '" + UserAccount + "')";  
        SqlCommand cmd3 = new SqlCommand(SQLStr, conn);  
        SqlDataAdapter sda = new SqlDataAdapter(cmd3);  
        DataTable dt = new DataTable();  
        sda.Fill(dt);  
        string posiStr = dt.Rows[0].ItemArray[0].ToString();  
        return posiStr;  
    }  
    protected bool UserDataChecker(string UserAccount)  
    {  
        SqlConnection conn = new SqlConnection("Data Source=(LOCAL);;Initial Catalog=BPMDB;User ID=sa;Password=1*********");  
        conn.Open();  
 
 
        string SQLStr = "SELECT  [string] FROM [index_position] WHERE (id_user = '" + UserAccount + "')";  
        SqlCommand cmd3 = new SqlCommand(SQLStr, conn);  
          
        SqlDataReader dr = cmd3.ExecuteReader();  
        if (dr.Read())  
        {  
            //not insert  
 
            return true;  
        }  
        else 
        {  
            //insert   
 
            return false;  
        }  
          
 
    }  
 
 
 
    private bool _dockStateCleared = false;  
    private List<DockState> CurrentDockStates  
    {  
        get 
        {  
 
              
            List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesMyPortal"];//UserDataLoader(AspxHelper.LoginUserAccount.ToString());  
              
 
             
            if (Object.Equals(_currentDockStates, null))  
            {  
                _currentDockStates = new List<DockState>();  
                Session["CurrentDockStatesMyPortal"] = _currentDockStates;  
 
            }  
 
 
            return _currentDockStates;  
        }  
        set 
        {  
 
            Session["CurrentDockStatesMyPortal"] = value;  
        }  
    }  
    //private List<DockState> CurrentDockStates = new List<DockState>();  
    protected void Page_Init(object sender, EventArgs e)  
    {  
        //if(UserDataChecker(AspxHelper.LoginUserAccount.ToString()))  
        //         CurrentDockStates = UserDataLoader(AspxHelper.LoginUserAccount.ToString());  
        foreach (DockState state in CurrentDockStates)  
        {  
            if (state.Closed == false)  
            {  
                RadDock dock = CreateRadDockFromState(state);  
                RadDockLayout1.Controls.Add(dock);  
                CreateSaveStateTrigger(dock);  
                LoadWidget(dock);  
            }  
        }  
          
 
    }  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
        PageHeader1.SelectedPageIndex = 0;  
        this.Title = "SmartBPM.NET--" + PageHeader1.SelectedPageName;  
        if (!IsPostBack)  
        {  
            DropDownZone.DataBind();  
        }  
    }  
 
      
 
    private void LoadWidget(RadDock dock)  
    {  
        if (string.IsNullOrEmpty(dock.Tag))  
        {  
            return;  
        }  
        Control widget = LoadControl(dock.Tag);  
        dock.ContentContainer.Controls.Add(widget);  
    }  
    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 RadDock CreateRadDockFromState(DockState state)  
    {  
        //建立一個dock並設定可用之動作(關閉、收合)  
        RadDock dock = new RadDock();  
        dock.DockMode = DockMode.Docked;  
        dock.ID = string.Format("RadDock{0}", state.UniqueName);  
        dock.ApplyState(state);  
        dock.Commands.Add(new DockCloseCommand());  
        dock.Commands.Add(new DockExpandCollapseCommand());  
 
        return dock;  
    }  
    private RadDock CreateRadDock(string title)  
    {  
        int docksCount = CurrentDockStates.Count;  
 
        RadDock dock = new RadDock();  
        dock.DockMode = DockMode.Docked;  
        dock.UniqueName = Guid.NewGuid().ToString();  
        dock.ID = string.Format("RadDock{0}", dock.UniqueName);  
        dock.Title = title;  
        dock.Text = string.Format("Added at {0}", DateTime.Now);  
        dock.Width = Unit.Pixel(300);  
 
        dock.Commands.Add(new DockCloseCommand());  
        dock.Commands.Add(new DockExpandCollapseCommand());  
 
        return dock;  
    }  
 
   
    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        //CurrentDockStates = UserDataLoader(AspxHelper.LoginUserAccount.ToString());  
        JavaScriptSerializer serializer = new JavaScriptSerializer();  
        string str = LoadUserData(AspxHelper.LoginUserAccount.ToString());  
        string[] currentDockStates2 = str.Split('|');   
        foreach (string stringState in currentDockStates2)   
        {  
            if (stringState != 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;  
        JavaScriptSerializer serializer = new 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();  
        bool ExistOrNot = UserDataChecker(AspxHelper.LoginUserAccount.ToString());  
        SqlConnection conn = new SqlConnection("Data Source=(LOCAL);;Initial Catalog=BPMDB;User ID=sa;Password=16*******");  
        conn.Open();  
        if (ExistOrNot)  
        {  
            //update  
            string SQLStr = "UPDATE index_position SET string='" + dockState + "' WHERE id_user = '" + AspxHelper.LoginUserAccount + "'";  
            SqlCommand cmd3 = new SqlCommand(SQLStr, conn);  
            cmd3.ExecuteNonQuery();  
        }  
        else 
        {  
            //insert  
            string SQLStr = "INSERT INTO index_position(id_user,string)VALUES('" + AspxHelper.LoginUserAccount + "','" + dockState + "')";  
            SqlCommand cmd3 = new SqlCommand(SQLStr, conn);  
            cmd3.ExecuteNonQuery();  
        }  
 
         
    }  
 
    public ArrayList GetZones()  
    {  
        ArrayList zones = new ArrayList();  
        zones.Add(RadDockZone1);  
        zones.Add(RadDockZone2);  
 
        return zones;  
    }  
 
    protected void ButtonAddDock_Click(object sender, EventArgs e)  
    {  
        RadDock dock = CreateRadDock(DroptDownWidget.SelectedItem.Text);  
 
        //find the target zone and add the new dock there  
        RadDockZone dz = (RadDockZone)FindControl(DropDownZone.SelectedItem.Text);  
        dz.Controls.Add(dock);  
 
        CreateSaveStateTrigger(dock);  
 
        //Load the selected widget in the RadDock control  
        dock.Tag = DroptDownWidget.SelectedValue;  
        LoadWidget(dock);  
    }  
    protected void ButtonPostBack_Click(object sender, EventArgs e)  
    {  
         
    }  
    protected void ButtonClear_Click(object sender, EventArgs e)  
    {  
         
    }  
     
}  
 
Pero
Telerik team
 answered on 16 Dec 2009
1 answer
82 views
How can I have the image of the selected item show in the combo box itself?
Princy
Top achievements
Rank 2
 answered on 16 Dec 2009
3 answers
132 views
I have the grid with the following settings.  What is happening is when I click on the row the grid expands to the right and goes off screen.  What would be causing this?

 <telerik:RadGrid ID="RadGrid2"    
          AllowMultiRowSelection="True"   
          AllowSorting="True" 
          AllowNaturalSort="True"   
          AutoGenerateColumns="False"   
          AlternatingItemStyle-HorizontalAlign="Center" 
          BackColor="#ffffff"   
          CellPadding="2"   
          CellSpacing="2"   
          GridLines="None"   
          GroupingEnabled="False" 
          HeaderStyle-Height="20"   
          Height="200"   
          ItemStyle-HorizontalAlign="Center"   
          OnItemCommand="RadGrid2_ItemCommand"   
          OnItemDataBound="RadGrid2_ItemDataBound"   
          SelectedItemStyle-ForeColor="#000000"                         
          SelectedItemStyle-BackColor="lightyellow"    
          ShowHeader="True"   
          Skin="Telerik"   
          Width="100%"   
          runat="server">  
 
   <MasterTableView AllowMultiColumnSorting="False" DataKeyNames="ID,NUMBER" EditMode="InPlace" TableLayout="Fixed" HeaderStyle-Wrap="false" Width="100%">  
     <Columns> 
     .............  
     </Columns> 
    </MasterTableView> 
         <ClientSettings AllowColumnsReorder="True">  
             <Resizing AllowColumnResize="True" AllowRowResize="False" ResizeGridOnColumnResize="False" /> 
             <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"/>  
             <Selecting AllowRowSelect="True" /> 
          </ClientSettings> 
</telerik:RadGrid> 
Pavlina
Telerik team
 answered on 16 Dec 2009
3 answers
603 views
Hi

I'm busy building a project where I've added the RadMenu into my master page, I populate the menu items with a datatable.
I need the user to be able to open the menu items including the root items in a new tab / window when right clicking on the menu items (as if right clicking on a hyperlink).
This option only seems to be available when you set the ImageUrl property in the individual menu items. Is there a way around this or do I have to use hyperlinks as item templates?

Regards
Erika
Kamen Bundev
Telerik team
 answered on 16 Dec 2009
1 answer
90 views
I'm having an issue with the MOSSRadEditor control. It was working now it's not anymore. I get a javascript error on the page OnClientModeChange is undefined.

the code is this
protected MOSSRadEditor _txtSummary;  
_txtSummary = new MOSSRadEditor();  
_txtSummary.ID = "txtSummary";  
_txtSummary.Height = Unit.Pixel(300);  
 
//getting content  
_txtSummary.Content = Item["Summary"].ToString();  
 
//setting content  
Item["Summary"] = _txtSummary.Content; 

The control render the box on the page, but no tool bars and the content zone is not clickable.

Lini
Telerik team
 answered on 16 Dec 2009
3 answers
93 views
Hello,

I am using RadControls for ASP.NET AJAX v2009.2.1028.35.

I am having this weird error in IE8 (I tested so far also in Chrome and no error) when using insertItems method:

Line: 2423
Error: 'this._element' is null or not an object

but it happens only when I am inserting lots of items (starting at ~ 4000). Anyway, after this error, the items are properly inserted.

Can you help me on this please?

Thank you very much for your products and support!
Genady Sergeev
Telerik team
 answered on 16 Dec 2009
7 answers
113 views
Hi,
I have a calendar made up of usercontrols inside a table, each of the controls are added as targets to the RadToolTipManager (this manager is cleared of targets before adding new ones).

Everything works fine using the load on demand except I have 2 linkbuttons to change the month of the calendar. These have not been added as targets but on selecting them the AjaxUpdate event is fired first.

I have read the blogs and posts regarding ToolTipManager but can't seem to stop this unwantred event from happening. Below is the code for the tooltipmanager:
<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"   
        Position=BottomCenter   
        ContentScrolling=Auto   
        AutoTooltipify="false"   
        HideDelay=5000 
        Animation="Fade"   
        Skin="Office2007"   
        Width="450px"   
        Height="200px"   
        ManualClose=false   
        OnAjaxUpdate="RadToolTipManager1_AjaxUpdate"   
        OnClientBeforeShow="tooltipPosition" 
        Style="font-size: 18px; text-align: center; font-family: Arial;">  
        </telerik:RadToolTipManager> 

 

 


with the javascript for the OnClientBeforeShow being:

 

    function tooltipPosition(sender, args) {  
        sender._popupBehavior.set_keepInScreenBounds(false);  
    }  
 

The version is 2009.1.311.35.

Any suggestions?

Regards
Roger

 

 

Svetlina Anati
Telerik team
 answered on 16 Dec 2009
1 answer
62 views
Hello,

I placed a RadGrid on a page that is being refreshed by an ajax timer.
When the user wants to scroll the grid I disable the timer to prevent unexpected behaviour.

Therefore I placed a div arround the grid with an OnMouseDown event attached.
In that event I disable the timer and wire up an OnMouseUp event for document.body.
This works fine in Firefox but in IE the MouseUp event will not be fired when I click on the scrollbar of the grid.
All other locations seems to work.

How can I disable the ajax timer from script when the user scrolls the grid and reenable the timer when the user stops scrolling?

Javascript

function Timer_Disable() {
 document.body.onmouseup = Timer_Enable;

 //   disable the Timer so we don't refresh the page
 //   while the user is entering the data
 var timer = $find(timerId);
 timer._stopTimer();

 window.status = "Refresh disabled during scrolling operation.";
}

function Timer_Enable() {
 document.body.onmouseup = null;

 //   re-enable the Timer
 var timer = $find(timerId);
 timer._startTimer();

 window.status = "";
}   


Code behind

divTimer.Attributes.Add(

"OnMouseDown", "Timer_Disable();");

 



Regards,

Jeroen
Dimo
Telerik team
 answered on 16 Dec 2009
1 answer
190 views
Hello All,              
             We have used "autosize=true" for radwindow, but the radwindow is not getting autosized after the content on the page changes instead the horizontal and vertical scrollbars are coming. We are using AjaxPanel.
As you have specified that "The size of the content page is taken in window.onload. This means that if you change the size of the content page with Ajax, the RadWindow will not resize after the new content is displayed.".
 Can you please tell us know where the problem is?
           We have also tried with the following code on the Page_Load(). It is helping in autosizing, but on the continuous button clicks the size of the  rad window grows horizontally till the end of the browser reaches.

  #region RadWindow AutoSize
        public void EnableRadWindowAutoSize(RadAjaxPanel radAjaxPanel, Label messageLabel)
        {
            radAjaxPanel.Controls.Add(SetRadWindowSizeRadScriptBlock(messageLabel));
        }
        public void EnableRadWindowAutoSize(RadAjaxManager radAjaxManager, Label messageLabel)
        {
            radAjaxManager.Controls.Add(SetRadWindowSizeRadScriptBlock(messageLabel));
        }
        private RadScriptBlock SetRadWindowSizeRadScriptBlock(Label messageLabel)
        {
            RadScriptBlock radScriptBlock = new RadScriptBlock();
            System.Text.StringBuilder scriptContent = new System.Text.StringBuilder();
            scriptContent.Append(@"
             <script type='text/javascript'>  
                function SetRadWindowSize(messageLabelID)
                {
                    try
                   {
                    var messageLabel = document.getElementById(messageLabelID);
                    if (messageLabel)
                      {                
                        if (messageLabel.innerHTML.length > 0)
                        {
                         var oWindow = null;
                         if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                         else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)
                         oWindow.autoSize();
                        }
                     }
                  }
                  catch (ex){}
              }");
            scriptContent.Append(String.Format("SetRadWindowSize('{0}')</script>", messageLabel.ClientID));
            radScriptBlock.Controls.Add(new LiteralControl(scriptContent.ToString()));
            return radScriptBlock;
        }
   #endregion

Please let us know if you have any solution.
Thanks,
Svetlina Anati
Telerik team
 answered on 16 Dec 2009
1 answer
75 views
Hello
i m using Radgrid,skin is Sunset,
now when in my page vertical scroll that time corner of vertical scroll is empty means no style there here i attached the screen shot and i m using Mozila Browser

Pavlina
Telerik team
 answered on 16 Dec 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?