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

Display RadWindow after canceling form_creating event

4 Answers 39 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Liem
Top achievements
Rank 1
Liem asked on 20 Nov 2008, 06:18 PM
Hi,
I have a scheduler, when user click to Edit Or Insert, I need to check if he is authenticated, and display a Login page in RadWindow if he is not authenticated.

protected void RadScheduler1_FormCreating(object sender, Telerik.Web.UI.SchedulerFormCreatingEventArgs e)
    {
        if ((e.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) || (e.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert))
        {
            if ((bool)Session["isAuthenticated"] == false)
            {
                //Run Script
                string script = "<SCRIPT LANGUAGE='JavaScript'> ";
                script += "return DisplayLogin()";
                script += "</SCRIPT>";
                ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", script);

                
                e.Cancel = true;//Cancel the Edit or Insert form
            }
        }

    }


And here is javaScript to display RadWindow

<script language="javascript" type="text/javascript">
        function DisplayLogin()
        {            
            var oRadWindow = $find("<%=LoginRadWindow.ClientID%>");            
            oRadWindow.show();
            oRadWindow.restore();
            return false;
        }
</script>

My problem is the script does not run because I cancel the form Create event and there are no post back.
Is there any way to make it happens
Thanks

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Nov 2008, 12:56 PM
Hello Liem,

You should handle the AppoitmentInsert and AppointmentUpdate events. You don't need to modify the rest of your code.

Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Liem
Top achievements
Rank 1
answered on 21 Nov 2008, 02:33 PM
Hello Peter,
Thanks for your quick reply.
The problem is AppoitmentUpdate (or AppointmentInsert) events happen after user do all the updating  in the form and clicked Update button.  And then they find out that they don't have right to update it. I am looking for a way to stop opening the update form if they don't have updating right. It would save them a lot of time.
Thanks
0
Peter
Telerik team
answered on 24 Nov 2008, 03:43 PM
Hello Liem,

In that case, you can use the server API of RadWindow. For example, try the following:
protected void RadScheduler1_FormCreating(object sender, Telerik.Web.UI.SchedulerFormCreatingEventArgs e)  
    {  
        if ((e.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) || (e.Mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert))  
        {  
            if ((bool)Session["isAuthenticated"] == false)  
            {  
                  
             RadWindow rw = new RadWindow();  
             rw.NavigateUrl = "login.aspx";  
             RadWindowManager1.Windows.Add(rw);  
             rw.VisibleOnPageLoad = true;                  
             e.Cancel = true;//Cancel the Edit or Insert form  
            }  
        }  
 
    } 


All the best,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Liem
Top achievements
Rank 1
answered on 24 Nov 2008, 04:18 PM
It works great. Thank you, Svetlina and Peter
Tags
Scheduler
Asked by
Liem
Top achievements
Rank 1
Answers by
Peter
Telerik team
Liem
Top achievements
Rank 1
Share this question
or