|
Article relates to
|
RadToolBar for ASP.NET v1.6.5.0
and
RadToolBar for ASP.NET AJAX
(Telerik.Web.UI v2008.1 XXX)
|
|
Created by
|
Peter, Telerik
|
|
Last modified by
|
Simon, Telerik
|
HOW-TO
Stretch RadToolBar to fit the width of the page.
SOLUTION
There are two ways of achieving the same effect:
I. Add
style="width: 100%;" to the ToolBar declaration;
II. Add
style="display: block; float: none" to the ToolBar declaration
SOLUTION
Since RadToolBar does not support width and height attributes (setting them has no effect), you could use one of the three approaches described below to achieve the desired effect.
I. Add
style="width: 100%;" to the ToolBar declaration:
| <rad:RadToolbar |
| ID="RadToolbar1" |
| runat="server" |
| Skin="Default" |
| DisplayEnds="true" |
| style="width: 100%;"> |
| ... |
| </rad:RadToolbar> |
This way the Buttons will also stretch proportionally to the width of the ToolBar.
II. Create a simple 'wrapper' ToolBar with a single RadToolBarTemplateButton. Add
style="width: 100%;" to the ToolBar declaration. In the Template put the 'real' ToolBar:
| <rad:RadToolbar |
| ID="RadToolbarWrapper" |
| runat="server" |
| Skin="Default" |
| DisplayEnds="true" |
| style="width: 100%;"> |
| <Items> |
| <rad:RadToolbarTemplateButton> |
| <ButtonTemplate> |
| <rad:RadToolbar |
| ID="RadToolBarReal" |
| runat="server" |
| Skin="Default" |
| DisplayEnds="false" |
| style="margin-left: 20%;"> |
| <Items> |
| ... |
| </Items> |
| </rad:RadToolbar> |
| </ButtonTemplate> |
| </rad:RadToolbarTemplateButton> |
| </Items> |
| </rad:RadToolbar> |
Add
style="margin-left: X%" to the 'real' ToolBar declaration to control its position in the 'wrapper' ToolBar Template.
The only downside of this approach is that another instance of RadToolBar is created on the page and more HTML is output. The next approach illustrates how this can be avoided.
III. Create a simple table with one row and three cells. Add appropriate classes and ids to the table structure, so that the default styles of RadToolBar apply to mimic the appearance and basic structure of a standard, 'real' RadToolBar:
| <table style="width: 100%;" id="<%=RadToolBarInner1.ClientID%>toolbar" cellspacing="0" cellpadding="0"> |
| <tr> |
| <td class="default_radtoolbar_left"> |
| <div style="width:5px"></div> |
| </td> |
| <td style="width: 100%;" class="default_radtoolbar_horizontal"> |
| ... |
| </td> |
| <td class="default_radtoolbar_right"> |
| <div style="width: 5px"></div> |
| </td> |
| </tr> |
| </table> |
Finally, add the ToolBar in the middle cell (the
'...' area in the code snippet above):
| <rad:RadToolbar |
| ID="RadToolBar1" |
| runat="server" |
| Skin="Default" |
| DisplayEnds="false" |
| style="margin-left: 40%;"> |
| <Items> |
| ... |
| </Items> |
| </rad:RadToolbar> |
Add
style="margin-left: X%" to the ToolBar declaration control to control its position in the middle table cell.