We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I get a reference to a Control on the Toolbar

Thread ID:

Created:

Updated:

Platform:

Replies:

116930 Jul 2,2014 05:34 PM Jul 4,2014 06:54 AM ASP.NET Web Forms (Classic) 3
loading
Tags: ToolBar
James Knowlton
Asked On July 2, 2014 05:34 PM

I have added a drop down calendar control to a toolbar using the TemplateItem (I'll post the HTML Markup at end of this message).  Basically I need to get a reference to the drop down calendar (ID="ddccDateSelection_") which is defined in the TollBarTemplateControl (ID="tbtcCSelectDate_") which is used by the TollBarItem (ID="tbiSelectDate_").  I need to be able to set the date in the control based on other actions take by the user on the page.
 
I've tried the "FindControl()" option but it always returns empty (Nothing).   If I use the debugger in Visual Studio I can use the existing reference to the toolbar itself and through the "Controls" property see the template, but I can't get to the actual drop down calendar control.
 
Here is the markup:
            <syncfusion:ToolBar ID="tbDailySchedule_" runat="server" AutoFormat="Office2007 Blue" Width="100%" OnClick="Toolbar_Click_" Locked="True">
               <Items>
                  <syncfusion:ToolBarItem ID="tbiDailySchedulePlus1Month_" Text="+1 Month" ToolTip="Increase the report date by one month" AppearanceMode="TextOnly" TextWrap="false" />
                  <syncfusion:ToolBarItem ID="tbiDailySchedulePlus1Week_" Text="+1 Week" ToolTip="Increase the report date by one week" AppearanceMode="TextOnly" TextWrap="false" />
                  <syncfusion:ToolBarItem ID="tbiDailySchedulePlus1Day_" Text="+1 Day" ToolTip="Increase the report date by one day" AppearanceMode="TextOnly" TextWrap="false" />
                  <syncfusion:ToolBarItem ID="tbiDailyScheduleToday_" Text="Today" ToolTip="Reset the report date to today's date" AppearanceMode="TextOnly" TextWrap="false" />                 
                  <syncfusion:ToolBarItem ID="tbiDailyScheduleMinus1Day_" Text="-1 Day" ToolTip="Decrease the report date by one day" AppearanceMode="TextOnly" TextWrap="false" />
                  <syncfusion:ToolBarItem ID="tbiDailyScheduleMinus1Week_" Text="-1 Week" ToolTip="Decrease the report date by one week" AppearanceMode="TextOnly" TextWrap="false" />
                  <syncfusion:ToolBarItem ID="tbiDailyScheduleMinus1Month_" Text="-1 Month" ToolTip="Decrease the report date by one month" AppearanceMode="TextOnly" TextWrap="False" />
                  <syncfusion:ToolBarItem ID="tbiSelectDate_" Text="Select Date" ButtonType="DropDown" TemplateID="tbtcCSelectDate_" />
                  <syncfusion:ToolBarItem Text="Item8" AppearanceMode="ImageOnly" ImageHoverPath="../CommonImages/Syncfusion_ToolBarSeperator.gif" 
                       ImagePath="../CommonImages/Syncfusion_ToolBarSeperator.gif" Look="emptylook" />
                  <syncfusion:ToolBarItem ID="tbiDailySchedulePrint_" Text="Print/PDF" ToolTip="Print the information displayed" AppearanceMode="TextOnly" TextWrap="False" />
                  <syncfusion:ToolBarItem ID="tbiDailyScheduleReport_" AppearanceMode="TextOnly" Disabled="True" Text="Report" TextWrap="False" ToolTip="Show the Comprehensive Report page" Visible="False" />
               </Items>
               <Templates>
                  <syncfusion:ToolBarTemplateControl ID="tbtcCSelectDate_" runat="server" ClientIDMode="Static">
                     <Template>
                        <syncfusion:DropDownCalendarControl ID="ddccDateSelection_" runat="server" AutoPostBackOnValueChanged="True" OnValueChanged="ddccDateSelection_onValueChaged_" ClientSideOnValueChange="ShowWaitingPopup_()" ClientIDMode="Static"
                           DayNameFormat="FirstLetter" CustomFormat="dd MMM yy" Format="CustomString" Width="100px" >
                        </syncfusion:DropDownCalendarControl>
                     </Template>
                  </syncfusion:ToolBarTemplateControl>
               </Templates>
            </syncfusion:ToolBar>         
Thanks,
 
James.
 

Ezhil S [Syncfusion]
Replied On July 3, 2014 07:48 AM

Hi James,

 

Thanks for your interest in Syncfusion products.

 

To set the date of the DropDownCalendar control embedded in ToolBar items using templates based on the selected items in toolbar, we suggest you to iterate the available controls in the Toolbar and find the DropDownCalendar control using the ID under ToolBar click event. Then you can set the date value for the control as required using Value property. Please refer the following code snippet,

 

<code>

[ASPX]

<syncfusion:ToolBar ID="tbDailySchedule_" runat="server" AutoFormat="Office2007 Blue" Width="100%" OnClick="Toolbar_Click_" Locked="True">

               <Items>

                  <syncfusion:ToolBarItem ID="tbiDailySchedulePlus1Month_" Text="+1 Month" ToolTip="Increase the report date by one month" AppearanceMode="TextOnly" TextWrap="false" />

                  <syncfusion:ToolBarItem ID="tbiDailySchedulePlus1Week_" Text="+1 Week" ToolTip="Increase the report date by one week" AppearanceMode="TextOnly" TextWrap="false" />

                  <syncfusion:ToolBarItem ID="tbiDailySchedulePlus1Day_" Text="+1 Day" ToolTip="Increase the report date by one day" AppearanceMode="TextOnly" TextWrap="false" />

                  <syncfusion:ToolBarItem ID="tbiDailyScheduleToday_" Text="Today" ToolTip="Reset the report date to today's date" AppearanceMode="TextOnly" TextWrap="false" />                 

                  <syncfusion:ToolBarItem ID="tbiDailyScheduleMinus1Day_" Text="-1 Day" ToolTip="Decrease the report date by one day" AppearanceMode="TextOnly" TextWrap="false" />

                  <syncfusion:ToolBarItem ID="tbiDailyScheduleMinus1Week_" Text="-1 Week" ToolTip="Decrease the report date by one week" AppearanceMode="TextOnly" TextWrap="false" />

                  <syncfusion:ToolBarItem ID="tbiDailyScheduleMinus1Month_" Text="-1 Month" ToolTip="Decrease the report date by one month" AppearanceMode="TextOnly" TextWrap="False" />

                  <syncfusion:ToolBarItem ID="tbiSelectDate_" Text="Select Date" ButtonType="DropDown" TemplateID="tbtcCSelectDate_" />

                  <syncfusion:ToolBarItem ID="tbiDailySchedulePrint_" Text="Print/PDF" ToolTip="Print the information displayed" AppearanceMode="TextOnly" TextWrap="False" />

                  <syncfusion:ToolBarItem ID="tbiDailyScheduleReport_" AppearanceMode="TextOnly" Disabled="True" Text="Report" TextWrap="False" ToolTip="Show the Comprehensive Report page" Visible="False" />

               </Items>

               <Templates>

                  <syncfusion:ToolBarTemplateControl ID="tbtcCSelectDate_" runat="server" ClientIDMode="Static">

                     <Template>

                        <syncfusion:DropDownCalendarControl ID="ddccDateSelection_" runat="server" AutoPostBackOnValueChanged="True" OnValueChanged="ddccDateSelection_onValueChaged_" ClientSideOnValueChange="ShowWaitingPopup_()" ClientIDMode="Static"

                           DayNameFormat="FirstLetter" CustomFormat="dd MMM yy" Format="CustomString" Width="100px" >

                        </syncfusion:DropDownCalendarControl>

                     </Template>

                  </syncfusion:ToolBarTemplateControl>

               </Templates>

            </syncfusion:ToolBar>

 

[CodeBehind]

        protected void Toolbar_Click_(object sender, Syncfusion.Web.UI.WebControls.Tools.ToolBarControl.ToolBarCommandEventArgs e)

        {

          

            foreach (Control control in tbDailySchedule_.Controls[0].Controls)

            {

                if (control.ID == "ddccDateSelection_")

                {

                    DropDownCalendarControl ddcl = (DropDownCalendarControl)control;

                    ddcl.CustomFormat = "MMM dd yyyy";

                    if (e.Item.ID == "tbiDailyScheduleToday_")

                        ddcl.Value = System.DateTime.Now;

                    if (e.Item.ID == "tbiDailyScheduleMinus1Day_")

                        ddcl.Value = System.DateTime.Now.AddDays(-1);

                    if (e.Item.ID == "tbiDailySchedulePlus1Day_")

                        ddcl.Value = System.DateTime.Now.AddDays(1);

                    if (e.Item.ID == "tbiDailySchedulePlus1Week_")

                        ddcl.Value = System.DateTime.Now.AddDays(7);

                    if (e.Item.ID == "tbiDailySchedulePlus1Month_")

                        ddcl.Value = System.DateTime.Now.AddMonths(1);

                    if (e.Item.ID == "tbiDailyScheduleMinus1Month_")

                        ddcl.Value = System.DateTime.Now.AddMonths(-1);

                    if (e.Item.ID == "tbiDailyScheduleMinus1Week_")

                        ddcl.Value = System.DateTime.Now.AddDays(-7);

                   

                }

            }           

        }

 

</code>

 

For your convenience we have modified your code to exhibit this behavior and it is available in the following link,

http://www.syncfusion.com/downloads/support/directtrac/general/Toolbar_f1169301956036904.zip

 

Kindly let us know if you have any other queries.

 

Regards,

Ezhil S


James Knowlton
Replied On July 3, 2014 10:52 AM

Thank you, that did the trick.

Ezhil S [Syncfusion]
Replied On July 4, 2014 06:54 AM

Hi James,

 

Thanks for the update.

 

We are glad to know that provided solution resolved the issue.

 

Hope we serve you better.

 

Kindly get back to us if you have further queries.

 

Regards,

Ezhil S


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;