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

[Solved] FormCreated event fires when AppointmentCommand Update button is clicked

3 Answers 100 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Sven
Top achievements
Rank 1
Sven asked on 12 Apr 2009, 01:56 AM

Hello,

I am using the AdvancedEditTemplate and prepopulating custom resources in the FormCreated event.  When I click the Update button on the edit form, the FormCreated event is firing again (before the AppointmentCommand event) and resetting all of the custom resources to their original values and wiping out the user's edits.

How can the Update button be configured to just fire the AppointmentCommand event without firing the FormCreated event first? 

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 13 Apr 2009, 09:01 AM
Hi Sven,

The FormCreated event is indeed fired each time the form is about to be rendered. Sometimes this event is used to add controls to the form, so these controls must be recreated before each postback.

One option is to keep a flag in the ViewState, so you can populate the form fields only on initial load.

Another option would be to attach the event handler in the Page_Load method. This way you will only receive the first event, as the subsequent ones are fired before this method.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Marco du Plessis
Top achievements
Rank 1
answered on 09 Sep 2009, 08:52 AM
Could you please send example of keep a flag in View State
0
Peter
Telerik team
answered on 09 Sep 2009, 02:32 PM
Hi Marco,

Here is an example:
protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e)  
    {  
        if (ViewState["FormCreatedFlag"] == "true")  
            return;  
        ViewState["FormCreatedFlag"] = "true";  
        Response.Write(DateTime.Now);  
    } 



Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Scheduler
Asked by
Sven
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Marco du Plessis
Top achievements
Rank 1
Peter
Telerik team
Share this question
or