Telerik Forums
UI for ASP.NET AJAX Forum
8 answers
432 views
Hi,

I'm working on the PortalSiteCS example provided by Telerik. 

I have updated one of the widgets to contain a label, a textbox and a button.  This is what I want: when the user types something into the textbox and clicks the button the label should be updated with the new value and in the database the value of Configuration should be updated with the new value.

For this to happen I trigger a postback when the user clicks the button inside the dock.  The button bubbles up an event to the parent - default page.  The default page gets the ID of the dock and the value of the label.  I enclosed DockLayout in and UpdatePanel and here I call update() on it hoping to trigger postback but that doesn't happen!  The new value is saved to the database so a second click on the button inside the dock does refresh the value of the label. 

Any clues as to why this is happening? I've attached code below:

Thanks.

Default.aspx
<asp:scriptmanager runat="server" id="ScriptManager1">  
</asp:scriptmanager> 
Widget Configuration:  
<asp:textbox maxlength="20" runat="server" id="TextConfiguration"></asp:textbox> 
<asp:dropdownlist runat="server" id="ListWidgets">  
</asp:dropdownlist> 
<asp:button runat="server" id="ButtonAddDock" text="Add Dock" onclick="ButtonAddDock_Click" /> 
 
 
 
<asp:UpdatePanel ID="ParentUpdatePanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional" > 
    <ContentTemplate> 
        <telerik:raddocklayout id="DockLayout" runat="server" onloaddocklayout="DockLayout_LoadDockLayout" 
            onsavedocklayout="DockLayout_SaveDockLayout" storelayoutinviewstate="false">  
            <div> 
                <telerik:raddockzone runat="server" id="ZoneLeft" style="float: left; margin-right: 10px;" 
                    width="45%" minheight="200px">  
                </telerik:raddockzone> 
                <telerik:raddockzone runat="server" id="ZoneRight" style="float: left;" minheight="200px" 
                    width="45%">  
                </telerik:raddockzone> 
            </div> 
            <div style="display: none">  
                <asp:updatepanel runat="server" id="UpdatePanel1">  
                    <triggers> 
                        <asp:asyncpostbacktrigger controlid="ButtonAddDock" eventname="Click" /> 
                    </triggers> 
                </asp:updatepanel> 
            </div> 
        </telerik:raddocklayout> 
   </ContentTemplate>                    
</asp:UpdatePanel> 
 

Default.aspx.cs
public partial class _Default : System.Web.UI.Page  
{  
    int PageID = 1;  
    List<PageWidgetInfo> _pageWidgets;  
 
    protected List<PageWidgetInfo> PageWidgets  
    {  
        get  
        {  
            if (_pageWidgets == null)  
            {  
                _pageWidgets = PageWidgetInfo.SelectPageWidgets(PageID);  
                _pageWidgets.Sort();  
            }  
            return _pageWidgets;  
        }  
    }  
 
    protected override void OnInit(EventArgs e)  
    {  
        foreach (PageWidgetInfo pageWidget in PageWidgets)  
        {  
            RadDock dock = CreateDock(pageWidget);  
 
            DockLayout.Controls.Add(dock);  
 
            CreateSaveStateTriggers(dock);  
        }  
        base.OnInit(e);  
    }  
 
    protected override void OnLoad(EventArgs e)  
    {  
        ScriptManager1.RegisterAsyncPostBackControl(TriggerAsyncPostback);  
 
        if (!IsPostBack)  
        {  
            ListWidgets.DataSource = WidgetInfo.Select();  
            ListWidgets.DataTextField = "Name";  
            ListWidgets.DataValueField = "ID";  
            ListWidgets.DataBind();  
        }  
 
        base.OnLoad(e);  
    }  
 
    protected RadDock CreateDock(PageWidgetInfo pageWidgetInfo)  
    {  
        RadDock dock = new RadDock();  
        dock.ApplyState(DockState.Deserialize(pageWidgetInfo.State));  
        dock.ID = pageWidgetInfo.ID.ToString();  
        dock.Tag = pageWidgetInfo.ID.ToString();  
 
        BaseWidget widget = LoadControl(pageWidgetInfo.Path) as BaseWidget;  
        if (widget == null)  
        {  
            throw new Exception(string.Format("The UserControl with path '{0}' does not inherit from BaseWidget. All widgets must inherit from BaseWidget.", pageWidgetInfo.Path));  
        }  
        widget.Configuration = pageWidgetInfo.Configuration;  
        dock.ContentContainer.Controls.Add(widget);  
          
 
        //Currently, there is a problem with the RadDock command items:  
        // if they are not explicitly created, the Command event it not fired.  
        dock.Commands.Add(new DockCloseCommand());  
        dock.Commands.Add(new DockExpandCollapseCommand());  
        dock.Command += new DockCommandEventHandler(Dock_Command);  
 
        return dock;  
    }  
 
    protected RadDock CreateDock(int widgetID, string widgetConfiguration)  
    {  
        WidgetInfo widget = WidgetInfo.Select(widgetID);  
        if (widget == null)  
        {  
            throw new Exception(string.Format("Cannot find a Widget with ID={0}.", widgetID));  
        }  
        PageWidgetInfo newPageWidget = PageWidgetInfo.Insert(PageID, widgetID, widgetConfiguration, string.Empty);  
        PageWidgets.Add(newPageWidget);  
 
        RadDock dock = CreateDock(newPageWidget);  
        dock.Title = widget.Name;  
 
        return dock;  
    }  
 
    protected 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 PageWidgetInfo FindWidget(int id)  
    {  
        foreach (PageWidgetInfo info in PageWidgets)  
        {  
            if (info.ID == id) return info;  
        }  
        return null;  
    }  
 
    protected void DockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        foreach (DockState state in DockLayout.GetRegisteredDocksState())  
        {  
            int stateWidgetID = int.Parse(state.Tag);  
 
            PageWidgetInfo pageWidget = FindWidget(stateWidgetID);  
            if (pageWidget != null && !state.Closed)  
            {  
                pageWidget.State = state.ToString();   
                pageWidget.Update();  
            }  
            else  
            {  
                PageWidgetInfo.Delete(stateWidgetID);  
            }  
        }  
    }  
 
    private void CreateSaveStateTriggers(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);  
    
    }  
 
    protected void ButtonAddDock_Click(object sender, EventArgs e)  
    {  
        RadDock dock = CreateDock(int.Parse(ListWidgets.SelectedValue), TextConfiguration.Text);  
 
        UpdatePanel1.ContentTemplateContainer.Controls.Add(dock);  
 
        CreateSaveStateTriggers(dock);  
 
        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, ZoneLeft.ClientID),  
            true);  
    }  
 
    protected void DockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        foreach (PageWidgetInfo pageWidget in PageWidgets)  
        {  
            e.Indices[pageWidget.DockState.UniqueName] = pageWidget.DockState.Index;  
            e.Positions[pageWidget.DockState.UniqueName] = pageWidget.DockState.DockZoneID;  
        }  
    }  
 
    protected override bool OnBubbleEvent(object source, EventArgs e)  
    {  
        Type type = source.GetType();  
        string souceName = type.ToString();  
 
        if ((e is CommandEventArgs) && souceName.Equals("System.Web.UI.WebControls.Button"))  
        {  
            Button temp = (Button)source;  
            if(temp.ID.Equals("Button1"))  
            {  
                TriggerAsyncPostback_Click(source, e);  
            }  
 
            return true;  
        }  
        return false;  
    }    
 
    protected void TriggerAsyncPostback_Click(object sender, EventArgs e)  
    {  
        CommandEventArgs args = (CommandEventArgs)e;  
        string configuration = (string)args.CommandArgument;  
        string ID = (string)args.CommandName;  
 
        //recreate it with the new data  
        PageWidgetInfo pageWidgetInfo = FindWidget(int.Parse(ID));  
        pageWidgetInfo.Configuration = configuration;  
 
        //delete all docks from the zones  
        foreach (RadDockZone zone in DockLayout.RegisteredZones)  
        {  
            zone.Controls.Clear();  
        }  
 
        //update DockLayout by updating the panel         
        ParentUpdatePanel.Update();  
    }  
} 



Lina
Top achievements
Rank 1
 answered on 19 Mar 2008
1 answer
97 views
Hi,

I found an error returned with the event from server when I was creating a Personal Site. The error ids were 5187 and 6151. We activated the RadEditor feature when the personal site is created. In our test case, if we create a few sites at the same time, it will be sucessful. But if we create many sites at the same time (12 sites/min), it always return an error.

The error message :

Microsoft.Office.Server.UserProfiles.PersonalSiteCreateException: A failure was encountered while attempting to create the site. ---> System.IO.IOException: The process cannot access the file 'C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\RadEditorList.ascx' because it is being used by another process.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)

at Telerik.SharePoint.RadEditorFeature.RadFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties)

at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)

at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce)
...

Best Regards,
lee

George
Telerik team
 answered on 19 Mar 2008
7 answers
181 views
I found runtime error every times to upload media in IE6. How should I do ? Please help.

OS: Window XP SP2
Browser: IE6 SP2

Reproducing Step
1.Create new post into personal blog
2.From Media manager click to upload and insert media file
3.After that security information windows will be displayed, click "Yes"
4.Then security information windows will be displayed again, click "Yes"
5. The Message error popup display (Microsoft Visual C++ Runtime Library)
Runtime Error !
Program C:\Program Files\Internet Explorer\iexplore.exe
R6025
-pire virtual function call

Best Regards,
lee
George
Telerik team
 answered on 19 Mar 2008
3 answers
1.6K+ views
I'm using a MySql SqlDataSource with the Rad Scheduler.

I loaded the page with the scheduler and clicked to add a new event, clicked insert and when the page reloaded I got this error:

Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'.

I looked in the database and it inserted everything properly, but it looks like it cannot convert my start_time, end_time columns for the select of the Scheduler. 

Any ideas on how to make this work?
Peter
Telerik team
 answered on 19 Mar 2008
3 answers
167 views

To customize a RadHtmlField we managed adding a project specific CSS file easily: 

   :
protected override void OnLoad(EventArgs e)
{
   base.OnLoad(e);
   base.radEditorControl.AllowScripts = true;
   base.radEditorControl.CssFiles = new string[]{ "/styles/css/styles.css" };
:


The editor shows all classes that can be found in styles.css in the "Apply CSS class" dropdown. Cool.

Beside a lot of other style definitions this CSS file contains classes like:

.SaiaStylesCustom-Saia-Text
{
 font-size: 12px;
 font-weight: normal;
 font-family: Arial, Helvetica, sans-serif;
 color: #212121;
}



We now would like to see just these .SaiaStylesCustom-xxx-xxx classes in the dropdown. Therefore we added the following in the OnLoad event handler:

   :
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.radEditorControl.AllowScripts = true;
base.radEditorControl.CssFiles = new string[] { "/styles/css/editorstyles.css" };

try
{
base.radEditorControl.CssClasses.Add(".SaiaStylesCustom-Saia-Text ", ".SaiaStylesCustom-Saia-Text");
:


We expected the dropdown to show just the classes we added, but we still can see all the other once present in the CSS file. Any idea what we're doing wrong? Help would be appreciated.

Rumen
Telerik team
 answered on 19 Mar 2008
5 answers
226 views
Hi there,

Unfortunately, the resource files only partly work. Most of the of expressions in RadEditor.Main.resx and RadEditor.Tools.resx are used by the editor and work fine, but not all of them. InsertTable, for instance, is ignored and the tooltip always displays "InsertTable" regardless of what is set in the resource files. It's the same thing with Undo, Redo, Background, and Foreground, and possibly more.

I also tried to set the radEditor.Localization.Tools.InsertTable string value in  codebehind, but this too is ignored...

And the resource files for the Table wizard, LinkManager, etc, do not work at all. I have copied them into the App_GlobalResources folder like I did with
RadEditor.Main.resx and RadEditor.Tools.resx, but neither the default language nor the Norwegian resource file I made is being used by the editor.

Is this a known issue in beta, or are these resource files supposed to fully work now? If so, what are the steps to make the resource files work 100%?

Regards,
TJ
Rumen
Telerik team
 answered on 19 Mar 2008
1 answer
129 views
Hi!

I need to update grid without collapse expanded rows after item insertion.

How i can do this?

Thanks.
Ves
Telerik team
 answered on 19 Mar 2008
3 answers
371 views
I need to disable the hover effects in the calendar, but the method given in the code samples for the old RadCalendar control gives a javascript error with the Prometheus control.  Altering the css to be the same as the default css is not a solution as the hover effect still happens and wipes out my custom highlighting.
Giuseppe
Telerik team
 answered on 19 Mar 2008
1 answer
99 views
Is it possible to do cross domain ajax requests?

I have 2 servers. One has all my image and video files and the other has the website pages.

I would like to be able to upload files to my file server and when finished send a signal to my website so that it knows it is done.

Is this possible?

My video server is something like this: videos.myDomain.com
My website is: myDomain.com

videos.myDomain.com and myDomain.com point to different servers.

Thanks,
Rosen
Telerik team
 answered on 19 Mar 2008
1 answer
66 views
Hi,

I have an existing Asp.Net AJAX application with multiple UpdatePanels. Now, I like to extend my app with the Prometheus Ajax and have some best practice questions. Have I change my hole app to support the Prometheus ajax? E.g. remove the existing Asp.Net ScriptManager, ScriptManagerProxy and UpdatePanels?

Many thanx 
Sebastian
Telerik team
 answered on 19 Mar 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?