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

problem of adding a user control button to triggers of updatepannel

4 Answers 69 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Edan Evantal
Top achievements
Rank 1
Edan Evantal asked on 07 Oct 2008, 08:50 AM
Hello dear representatives of Telerik.
I will explain you of what I am tryin to do and how I want it to work.
I do have a default page where I am adding dynamically controls (in raddocks)
like in your samples and want to add a custom command which will open me a window not yours an open window. In open window I am getting all the data (configuration) of Specific raddock control which is sent by session.

In edit window i change the data and make click on the button which is inside the raddock(ex: raddock has some news.ascx control which has some hidden button).

By clicking this hidden button I want it to save the changes and make a dopostback.

In all your samples you do have only two events added dynamically the dragging and closing the dock. I want to add to the triggers this button event as well for updating the data.

Thank you in advance.

4 Answers, 1 is accepted

Sort by
0
Accepted
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 10 Oct 2008, 02:00 PM

If you use the following example(MyPortal):
http://demos.telerik.com/ASPNET/Prometheus/Dock/Examples/MyPortal/DefaultCS.aspx

The code below is modified part of MyPortal example illustrates how to add custom ajaxified command:

 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";  
            dock.Text = string.Format("Added at {0}", DateTime.Now);  
            dock.Width = Unit.Pixel(300);  
            //YOUR CUSTOM COMMAND  
            DockCommand command = new DockCommand();  
            command.AutoPostBack = true;  
            command.Name = "CustomCommand";  
            dock.Commands.Add(command);  
            //END:YOUR CUSTOM COMMAND  
 
            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);  
 
            }  
            //HANDLE CUSTOM COMMAND  
            if (e.Command.Name == "CustomCommand")  
            {  
             //DO SOMETHING...  
            }  
 
        } 

Hope this helps!

0
Edan Evantal
Top achievements
Rank 1
answered on 12 Oct 2008, 06:23 AM
Hello Dear Obi, Thanks for your reply.
I don't need a command itself. I want somehow to change the visual side of the raddock when I click some button in the user control which is inside the raddock contol.
Example: I do have some iframe in the user control which recieves the url of some web site to be shown. I add some raddock command which opens a new window. In that window I recieve as a parameter the url of that iframe. Change it and click OK in the edit window. The data is saved in session.
From opened window I make a click on some hidden button inside the control and want the data to be refreshed inside the raddock.

As I see the initialization of raddocks should be done only during the page_init. And I think it should in the same manner as you have discribed above I mean after making the click in user control and making update in the database there should be a postback for initializing the control once more.

How is it done??? Cause you do all these postback via java script. Thanks in advance.
0
Edan Evantal
Top achievements
Rank 1
answered on 12 Oct 2008, 07:08 AM

here is a code of Hidden Button Click.
This is a way how I see it and it is not correct :(

 

 

protected void hiddenButton_Click(object sender, EventArgs e)

 

{

 

ScriptManager.RegisterStartupScript(

 

MyDock,

 

this.GetType(),

 

 

"RefreshDocking",

 

 

string.Format(@"function _RefreshDock() {{" +

 

 

"Sys.Application.remove_load(_RefreshDock);" +

 

 

"$find('{0}').doPostBack('DockPositionChanged');" +

 

 

"}};" +

 

 

"Sys.Application.add_load(_RefreshDock);", MyDock.ClientID),

 

 

true);

 

}

DockPositionChanged as I see is an event which should be called or my one for making update.

At this stage I recive all the data I need and I want only to make update to raddock.
MyDock I recive as a property from default.aspx.cs so i would be happy to see the answer.

0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 13 Oct 2008, 08:41 AM
I think that I could not completely understand   your scenario.
Keep in mind that the hidden button should be in the same document as the RadDock, e.g. if you put the button in iframe(or Radwindow) you will not be able to update the RadDock.

The code which you sent seems to be correct.The only one suggestion which I can give you is to invoke "alert('{0}');" Instead "$find('{0}').doPostBack('DockPositionChanged');" and see if the ID is correct.
Tags
Dock
Asked by
Edan Evantal
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Edan Evantal
Top achievements
Rank 1
Share this question
or