RadScheduler OnFormCreated Adding Controls

6 posts, 0 answers
  1. Daniel
    Daniel avatar
    3 posts
    Member since:
    May 2011

    Posted 01 Jun 2011 Link to this post

    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
  2. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 01 Jun 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 02 Jun 2011 Link to this post

    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.

  5. Daniel
    Daniel avatar
    3 posts
    Member since:
    May 2011

    Posted 02 Jun 2011 Link to this post

    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
  6. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 03 Jun 2011 Link to this post

    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
  7. Daniel
    Daniel avatar
    3 posts
    Member since:
    May 2011

    Posted 03 Jun 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017