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

[Solved] Is there a way to redirect to another page from a scheduler event?

9 Answers 462 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Rem
Top achievements
Rank 1
Rem asked on 06 Sep 2007, 05:32 AM
I have the following code:

    Protected Sub radEventScheduler1_FormCreating(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerFormCreatingEventArgs) Handles radEventScheduler1.FormCreating  
 
        e.Cancel = True 
 
        'Double clicked on appointment  
        If e.Mode = Telerik.Web.UI.FormMode.Insert Then 
 
            Response.Redirect("Page2.aspx"True)  
 
        ElseIf e.Mode = Telerik.Web.UI.FormMode.Edit Then 
 
            Response.Redirect("Page3.aspx, True)  
        Else 
            'Everything else - do nothing for now  
        End If 
 
    End Sub 
 

What I want to do is to direct to different pages depending on whether the user is trying to add a new appointment or edit an existing one.  I'm not sure if I used the correct radscheduler event for this (FormCreated).  I do know that response.redirect doesnt work due to the fact that this is based on microsoft ajax.  Is there a way to redirect to another page without using response.redirect?

Thanks

9 Answers, 1 is accepted

Sort by
0
RyanBoud
Top achievements
Rank 1
answered on 06 Sep 2007, 10:34 AM
Hi Rem,

I am doing exactly the same thing, and it works fine for me.

I am using FormCreated (not FormCreating!), as I need the Start and End times they clicked, but I'm sure FormCreating would work just as well.
this is my complete FormCreated handler:

if(e.Container.Mode == FormMode.Insert) { 
  Response.Redirect("AppointmentForms/?start=" + 
    e.Appointment.Start.ToString() + 
    "&finish=" + 
    e.Appointment.End.ToString()); 


0
Rem
Top achievements
Rank 1
answered on 06 Sep 2007, 10:41 PM
Hmm, it doesnt work for me.  I have also tried using the formcreated event (with the required code changes of course) and either way I get the error:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.  Common causes for this error are when the response is modified by calls to Response.Write(), response filters, or server trace is enabled.
Details:  Error parsing near'

<!DOCTYPE HTML P'.

0
T. Tsonev
Telerik team
answered on 08 Sep 2007, 10:15 AM
Hello Rem,

It looks like the redirect itself is working and the error seems to be AJAX-related. Are you using the official 1.0 version of the AJAX extensions for ASP.NET?

Greetings,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rem
Top achievements
Rank 1
answered on 09 Sep 2007, 08:54 PM
Yes I am using the official 1.0 version as downloaded from this page:
http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&displaylang=en

I have also tried this on another machine and the same problems occur.

0
Rem
Top achievements
Rank 1
answered on 11 Sep 2007, 11:20 PM
I have created a new page and copying most of the code from the old page seems to have done the trick and the new page is now working as intended (so far).

However, there is a bit of a snag.  When creating / editing an appointment, I have the following code:
Protected Sub radEventScheduler1_FormCreating(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerFormCreatingEventArgs) Handles radEventScheduler1.FormCreating  
 
        'Double clicked on appointment  
        If e.Mode = Telerik.Web.UI.FormMode.Insert Or e.Mode = Telerik.Web.UI.FormMode.AdvancedInsert Then 
 
            Response.Redirect("Insert.aspx?key=0"True)  
 
        ElseIf e.Mode = Telerik.Web.UI.FormMode.Edit Or e.Mode = Telerik.Web.UI.FormMode.AdvancedEdit Then 
 
            Dim a As Integer = radEventScheduler1.Appointments.Count  
 
            Response.Redirect("eventdetails.aspx?key=" & e.Appointment.ID.ToString.Trim, True)  
 
        Else 
            'Everything else?  
            'lblMessage.Text = "Everything Else"  
            Dim a As Telerik.Web.UI.FormMode  
            a = e.Mode  
        End If 
 
        e.Cancel = True 
 
    End Sub 

The redirecting on inserting an appointment works fine, but then I do the redirect for editing an appointment, I get the error "object reference not set to an intance of the object" for e.Appointment.ID.ToString.Trim.

Is there a way to get the ID that is passed to the radscheduler (i.e. the value in the DataKeyField property of the scheduler?

Again, thanks so much for your help and patience.
0
T. Tsonev
Telerik team
answered on 12 Sep 2007, 07:31 AM
Hi Remrick,

This is bug in the preview refresh version, FormCreating does not always receive an appointment and that is why you receive the null reference exception. As a workaround, attach to the FormCreated event instead. We will fix it for the official release.

There is the special case when dealing with recurrent appointments. When the user has chosen to create a recurrence exception you will still get a form in edit mode, but the appointment will have an empty ID (null in current development builds) and it will be in the "Exception" state. In essence, you are expected to show an edit form in this case, but perform an insert on submit.

Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rem
Top achievements
Rank 1
answered on 12 Sep 2007, 10:14 PM
I have tried putting the code in the FormCreatedEvent instead and found another problem.  When I try to edit an existing or create a new appointment it returns with the error in the following line in the scriptresource.axd file:

},Hide:function(_9){  
var _a=document.getElementById(_9);  
var _b=(!this.IsSticky)?document.getElementById(this.get_element().id+_9):this.get_element();  
var _c=new Date();  
if(_b==null){  
return;  

The error occurs on the var_b line, saying "Microsoft JScript runtime error: 'this.get_element().id' is null or not an object"

I note that this error only occurs if the current viewtype is not the same as the starting viewtype.

For example, if I set Scheduler1.viewtype = SchedulerViewType.DayView in the code behind page at page load, then the error doesnt happen when I create a new appointment in day view, but when I click on week or month to change the viewtype, then create or edit an appointment, then the error occurs.  If I set the viewtype to weekview in the page load, then creating or editing an appointment in weekview is fine, but the error occurs when I go to day or month view and try to create it there.

If I change the viewtype by clicking on month or day and go back to weekview (which was the starting view) then the error occurs as well so it might have something to do with changing the view type.

0
T. Tsonev
Telerik team
answered on 17 Sep 2007, 07:21 AM
Hi Remrick,

I am sorry for the late response. We are busy putting the final touches to the Q2 release and it will be available soon. You can monitor this forum thread for the latest announcements regarding the release.

I did not manage to reproduce the problem with the preview refresh version. I am attaching my test project, so you can verify that we are doing the same thing.

Try the the same example with the official Q2 release, when it is available. If the problem persists, please send your test project to support@telerik.com and include "RadScheduler #97928" in the subject line, so we can debug it locally.

All the best,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rem
Top achievements
Rank 1
answered on 24 Sep 2007, 12:33 AM
This is no longer an issue with the latest release of the prometheus controls.  Thanks so much for the help and patience.  :)
Tags
Scheduler
Asked by
Rem
Top achievements
Rank 1
Answers by
RyanBoud
Top achievements
Rank 1
Rem
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or