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

Accessing AdvancedEditForm Save Button

1 Answer 104 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 14 Jun 2013, 08:37 PM

I'm trying to access the AdvancedEditForm save button to disable in a certain case and looking at AdvancedForm.ascx, I should be able to get to it by using:

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
    {
  
        if (e.Container.Mode == SchedulerFormMode.AdvancedInsert)
        {
            ((LinkButton)((Panel)e.Container.FindControl("ButtonsPanel")).FindControl("UpdateButton")).Enabled = false;
        }
    }

Unfortunately the program throws an "Object reference not set to an instance of an object." when it runs into that line of code. How can I access the save button? Please note I need to do it in the FormCreated event because I need to know the SchedulerFormMode value.

Also, how would I access the room and user resource dropdowns?

Thanks,
Matt

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 18 Jun 2013, 01:27 PM
Hello,

Thank you for contacting Telerik Support.

Please find below an easy and conveninet way of accessing the "Update" link button and the room resource RadComboBox controls. 
//markup code

<telerik:RadScheduler runat="server" ID="RadScheduler1"...
            OnFormCreated="RadScheduler1_FormCreated"
            .....
            <AdvancedInsertTemplate>
                <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert" Subject='<%# Bind("Subject") %>'
                    Start='<%# Bind("Start") %>' End='<%# Bind("End") %>' Description='<%# Bind("Description") %>'
                    RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' Reminder='<%# Bind("Reminder") %>'
                    AppointmentColor='<%# Bind("AppointmentColor") %>' UserID='<%# Bind("User") %>'
                    RoomID='<%# Bind("Room") %>' TimeZoneID='<%# Bind("TimeZoneID") %>'   />
            </AdvancedInsertTemplate>
            ...
        </telerik:RadScheduler>
//user control markup code
<asp:Panel runat="server" ID="ResourceControls">
                        <%-- RESOURCE CONTROLS --%>
                        <ul class="rsResourceControls">
                            <li>
                                <!-- Resource controls should follow the convention Res[Resource Name] for ID -->
                                <scheduler:ResourceControl runat="server" ID="ResRoom" Type="Room" Label="Room:"
                                    Skin='<%# Owner.Skin %>' />
                            </li>
                            ....
                        </ul>
                    </asp:Panel>
//code behind
protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
        {
            if (e.Container.Mode == SchedulerFormMode.AdvancedInsert)
            {
                //update Button
                LinkButton update = e.Container.FindControl("AdvancedInsertForm1").FindControl("ButtonsPanel").FindControl("UpdateButton") as LinkButton;
                //room resource RadComboBox control
                RadComboBox resource = e.Container.FindControl("AdvancedInsertForm1").FindControl("ResRoom").FindControl("ResourceValue") as RadComboBox;
            }
        }

Please note that I have highlighted the ID of the nested containers - the advanced form and the panel. 

Hope that this will be helpful.

Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Scheduler
Asked by
Matt
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or