Hello,
I have created an image button in the titlebar of a RadDock and am trying to execute a command when the user clicks on this button. I'm basically trying to get the RadDock to collapase or expand when this imagebutton is clicked. I don't want to do a postback either...so it needs to hit JavaScript.
ImageButton btnDocExpand = new ImageButton();
btnDocExpand.ImageUrl = "Vista/Dock/rdExpand.gif";
btnDocExpand.OnClientClick = "btnExpand_ONCLICK";
btnDocExpand.AlternateText = "Expand";
btnDocExpand.ID = woAlert.title + "Expand";
rdoAlert.TitlebarContainer.Controls.Add(btnDocExpand);
Thanks!!
Travis
I have created an image button in the titlebar of a RadDock and am trying to execute a command when the user clicks on this button. I'm basically trying to get the RadDock to collapase or expand when this imagebutton is clicked. I don't want to do a postback either...so it needs to hit JavaScript.
ImageButton btnDocExpand = new ImageButton();
btnDocExpand.ImageUrl = "Vista/Dock/rdExpand.gif";
btnDocExpand.OnClientClick = "btnExpand_ONCLICK";
btnDocExpand.AlternateText = "Expand";
btnDocExpand.ID = woAlert.title + "Expand";
rdoAlert.TitlebarContainer.Controls.Add(btnDocExpand);
Thanks!!
Travis
3 Answers, 1 is accepted
0
Accepted
Hi Ken,
Thank you for contacting us.
Please, look at the following code. It shows how to achieve the functionality you have described:
aspx code :
If you want your page not to make a postback after a client click event just add return false at the end of bntExpand_ONCLICK() declaration.
Let me know, if you need further assistance.
Kind regards,
Dimcho
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for contacting us.
Please, look at the following code. It shows how to achieve the functionality you have described:
aspx code :
function btnExpand_ONCLICK() |
{ |
var dock = $find("<%=RadDock1.ClientID %>"); |
var Collapsed = dock.get_Collapsed(); |
if(Collapsed) |
{ |
dock.set_Collapsed(false); |
} |
else |
{ |
dock.set_Collapsed(true); |
} |
} |
If you want your page not to make a postback after a client click event just add return false at the end of bntExpand_ONCLICK() declaration.
btnDocExpand.OnClientClick = "btnExpand_ONCLICK(); return false;" ; |
Let me know, if you need further assistance.
Kind regards,
Dimcho
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
David
Top achievements
Rank 1
answered on 27 Mar 2008, 06:17 PM
I'm having a hard time locating the Dock with the find function.
Within rdzMain I am dynamically creating the docks.
The javascript example you gave hasn't worked for me as I can't seem to find anything within rdzMain.
Thank for all the help so far!
Travis
<telerik:RadDockLayout ID="rdlMain" runat="server" EnableEmbeddedSkins="false" Skin="Vista"> | |
<telerik:RadDockZone ID="rdzMain" FitDocks="false" Orientation="vertical" runat="server" Width="100%" BorderWidth="0" BorderColor="gray"> | |
</telerik:RadDockZone> | |
</telerik:RadDockLayout> |
Within rdzMain I am dynamically creating the docks.
RadDock rdoAlert = new RadDock(); | |
//rdoAlert.Pinned = true; //doesn't allow dragging | |
rdoAlert.Text = woAlert.title; | |
rdoAlert.ID = woAlert.uID; | |
rdoAlert.UniqueName = woAlert.uID; | |
rdoAlert.Width = Unit.Percentage(100); | |
rdoAlert.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None; | |
rdoAlert.ToolTip = woAlert.toolTip; | |
rdoAlert.Title = woAlert.title; | |
rdoAlert.AutoPostBack = false; | |
Label lblDockTitle = new Label(); | |
lblDockTitle.Text = " "+woAlert.title; | |
lblDockTitle.Font.Size = FontUnit.Point(11); | |
lblDockTitle.Font.Bold = true; | |
ImageButton btnDocExpand = new ImageButton(); | |
btnDocExpand.ImageUrl = "Vista/Dock/rdExpand.gif"; | |
btnDocExpand.AlternateText = "Expand"; | |
btnDocExpand.ID = woAlert.title + "Expand"; | |
const string onClientClick = "btnExpand_ONCLICK('{0}', '{1}'); return false;"; | |
btnDocExpand.OnClientClick = string.Format(onClientClick, btnDocExpand.ClientID, "blue"); | |
rdoAlert.TitlebarContainer.Controls.Add(btnDocExpand); | |
rdoAlert.TitlebarContainer.Controls.Add(lblDockTitle); | |
System.Drawing.ColorConverter conv3 = new System.Drawing.ColorConverter(); | |
System.Drawing.Color c3 = (System.Drawing.Color)conv3.ConvertFromString("#69A637"); | |
rdoAlert.TitlebarContainer.BackColor = c3; | |
rdoAlert.TitlebarContainer.ForeColor = System.Drawing.Color.Black; | |
rdoAlert.TitlebarContainer.Font.Size = FontUnit.Point(11); | |
System.Drawing.ColorConverter conv = new System.Drawing.ColorConverter(); | |
System.Drawing.Color c = (System.Drawing.Color)conv.ConvertFromString("#F6F6F6"); | |
rdoAlert.BackColor = c; | |
System.Drawing.ColorConverter conv2 = new System.Drawing.ColorConverter(); | |
System.Drawing.Color c2 = (System.Drawing.Color)conv2.ConvertFromString("#CCCCCC"); | |
rdoAlert.BorderColor = c2; | |
rdoAlert.ContentTemplate = Page.LoadTemplate(woAlert.url); | |
switch (woAlert.columnNum) | |
{ | |
case 0: //corresponds to the main docking area | |
rdzMain.Controls.Add(rdoAlert); | |
break; | |
case 1: | |
break; | |
case 2: | |
break; | |
default: | |
break; | |
} |
The javascript example you gave hasn't worked for me as I can't seem to find anything within rdzMain.
Thank for all the help so far!
Travis
0
Accepted
David
Top achievements
Rank 1
answered on 27 Mar 2008, 06:32 PM
Figured this out....just had to use the FindControl method see below...
var dock1 = $find("<%= rdzMain.FindControl("widgetSetup").ClientID %>");
Thanks!
Travis
var dock1 = $find("<%= rdzMain.FindControl("widgetSetup").ClientID %>");
Thanks!
Travis