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

RadScheduler OnFormCreated Adding Controls

5 Answers 170 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 01 Jun 2011, 09:20 PM
Hello,

I am trying to add a link button to the Advanced Form by handling the OnFormCreated event. here is my code:

protected void RadScheduler_FormCreated(object sender, SchedulerFormCreatedEventArgs  e)
    {
        if (e.Container.Mode == SchedulerFormMode.AdvancedEdit)
        {
            LinkButton l = new LinkButton();
            l.Text = "Additional Info";
            l.ForeColor = Color.White;
            l.PostBackUrl = "some url";
            e.Container.Controls.Add(l);
        }
    }

When I execute the code, I can confirm that the e.Container.Controls collection is being updated (the Count went up by 1 and I can query the last control and it is t\my LinkButton), but the LinkButton button is not visible on the form.

Am I doing anything wrong?

Thank you,
Daniel

5 Answers, 1 is accepted

Sort by
0
Gimmik
Top achievements
Rank 1
answered on 01 Jun 2011, 10:00 PM
Hi Daniel,

I think I know what your issue may be. If I'm right you're going to laugh at yourself, I did when I made the same mistake. You're creating your new control by wiring up the OnFormCreated event (that gets fired after the form is created,) try using the OnFromCreating event (that gets fired before the form is created.)

Let me know if that works for you,
-Gimmik
0
Veronica
Telerik team
answered on 02 Jun 2011, 07:01 AM
Hi Gimmik and Daniel,

Lord Gimmik is absolutely right about the events. OnFormCreating is early enough to add controls to the advanced form. Another possible solution is to use AppointmentTemplate as shown in this demo.

Greetings,
Veronica Milcheva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Daniel
Top achievements
Rank 1
answered on 02 Jun 2011, 05:22 PM
Thank you both for your help,

I was thinking the same thing since the name Created already implies that the Control Collection is already populated. However, I was looking at this post http://www.telerik.com/community/forums/aspnet-ajax/scheduler/dropdown-control-in-rad-scheduler.aspx and since the code there was posted by a member of the Telerik team, I assumed that this was the way to go and that I was doing something wrong.

I have one question regarding your suggestion: if I use OnFormCreating, SchedulerFormCreatingEventArgs does not expose the Container object. How do I add the control to the control collection?

Thank you,
Daniel
0
Gimmik
Top achievements
Rank 1
answered on 03 Jun 2011, 05:31 PM
Hi Daniel,

That's a great point you make there. Now I'm the one that feels silly. :)  I would guess that the container isn't exposed because it isn't actually created at the time the OnFormCreating event gets fired. I would try the AppointmentTemplate method that Veronica suggested. That seems like it will be easier. If that doesn't work for you let me and and maybe we can come up with something.

-Gimmik
0
Daniel
Top achievements
Rank 1
answered on 03 Jun 2011, 06:49 PM
Thank you Gimmik,

It is strange that a simple task like this one will require the developer to rebuild the whole appointment edit template. I am sure that I am not the first one that wants to add a simple control to the automatically created template.

Thank you for your help,
Daniel
Tags
Scheduler
Asked by
Daniel
Top achievements
Rank 1
Answers by
Gimmik
Top achievements
Rank 1
Veronica
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or