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

Redwindowpopup not working on- Scheduler - Resource Grouping

1 Answer 32 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
aakash
Top achievements
Rank 1
aakash asked on 06 Mar 2018, 06:39 AM

Run javascript from code behind

I know that there are a lot of question like this. I tried a lot them, but still cant make it working.

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeBehind="ScheduleAppointment.aspx.cs" Inherits="iCRA_UI.FieldTech.ScheduleAppointment" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <title></title>

 
    <script src="lib/qsf.js"></script>
    <link href="lib/qsf.css" rel="stylesheet" />
    <script src="poupup.js"></script>



   
</head>
<body>
    <form id="form1" runat="server">


 <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />

     <telerik:RadWindowManager RenderMode="Lightweight" ID="RadWindowManager1" runat="server" EnableShadow="true">
        </telerik:RadWindowManager>


   
    <telerik:RadAjaxManager   ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ConfigurationPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
        <div class="demo-container no-bg">
            <telerik:RadScheduler RenderMode="Lightweight" runat="server" ID="RadScheduler1" GroupBy="Speaker" CustomAttributeNames="Completed" GroupingDirection="Horizontal"
                OnNavigationCommand="RadScheduler1_NavigationCommand"
                AppointmentStyleMode="Default" DataSourceID="EventsDataSource" DataKeyField="ID"
                FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" DataSubjectField="Description"  RowHeight="40px" EnableTimeZonesEditing="true"
                DataStartField="StartTime" DataEndField="EndTime" DataRecurrenceField="RecurrenceRule"
                SelectedView="DayView" DataRecurrenceParentKeyField="RecurrenceParentID" AllowInsert="true" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnAppointmentDelete="RadScheduler1_AppointmentDelete"  OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnResourceHeaderCreated="RadScheduler1_ResourceHeaderCreated"
               
                OverflowBehavior="Auto">
                <AdvancedForm Modal="true"></AdvancedForm>
                <MonthView UserSelectable="true"></MonthView>
                <TimelineView />
                <ResourceHeaderTemplate>
                    <asp:Panel ID="ResourceImageWrapper" runat="server" CssClass="ResCustomClass">
                        <asp:Image ID="SpeakerImage" runat="server" AlternateText='<%= Eval("Text") %>'></asp:Image>
                    </asp:Panel>
                </ResourceHeaderTemplate>
                <ResourceTypes>
                    <telerik:ResourceType KeyField="UserID" Name="Speaker" TextField="Fullname" ForeignKeyField="UserID"
                        DataSourceID="SpeakersDataSource1"></telerik:ResourceType>
                </ResourceTypes>
                <ResourceStyles>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="1" BackColor="#eb901b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="2" BackColor="#8fd21b"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="3" BackColor="#278ce9"></telerik:ResourceStyleMapping>
                    <telerik:ResourceStyleMapping Type="Speaker" Key="4" BackColor="#f14db2"></telerik:ResourceStyleMapping>
                </ResourceStyles>
                <TimeSlotContextMenuSettings EnableDefault="true"></TimeSlotContextMenuSettings>
                <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
            </telerik:RadScheduler>
        </div>
    </telerik:RadAjaxPanel>

    
    <asp:SqlDataSource ID="SpeakersDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:SQL %>" SelectCommand="SELECT * FROM [user_view]"
        >
    </asp:SqlDataSource>

          <asp:SqlDataSource ID="SpeakersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="SELECT * FROM [sp_view]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="EventsDataSource" runat="server"
        ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
        SelectCommand="SELECT * FROM [sp_view]" InsertCommand="INSERT INTO [sp_view] ([Description], [StartTime], [EndTime], [SpeakerID]) VALUES (@Description, @Start, @End, @SpeakerID)"
       UpdateCommand="UPDATE [sp_view] SET [Description] = @Description, [Start] = @Start, [End] = @End, [RoomID] = @RoomID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [UserID] = @SpeakerID WHERE [UserID] = @ID"
        DeleteCommand="DELETE FROM [sp_view] WHERE [UserID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Description" Type="String"></asp:Parameter>
            <asp:Parameter Name="Start" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="End" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="RoomID" Type="Int32" DefaultValue="1"></asp:Parameter>
            <asp:Parameter Name="RecurrenceRule" Type="String"></asp:Parameter>
            <asp:Parameter Name="RecurrenceParentID" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="SpeakerID" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
        </UpdateParameters>
     <InsertParameters>
            <asp:Parameter Name="Description" Type="String"></asp:Parameter>
            <asp:Parameter Name="Start" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="End" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="RoomID" Type="Int32" DefaultValue="1"></asp:Parameter>
            <asp:Parameter Name="RecurrenceRule" Type="String"></asp:Parameter>
            <asp:Parameter Name="RecurrenceParentID" Type="Int32"></asp:Parameter>
            <asp:Parameter Name="SpeakerID" Type="Int32"></asp:Parameter>
        </InsertParameters>
    </asp:SqlDataSource>
 

    <div >


    <asp:Button ID="Button1" OnClick="Button1_Click"  runat="server" Text="Button" />
            </div>
 

    </form>
</body>
</html>

code behind cs.code

     protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {




            ScriptManager.RegisterStartupScript(Page, this.GetType(), "testOne", "MyFunction();", true);
            DateTime start = e.Appointment.Start;
            DateTime end = e.Appointment.End;
            string name = e.Appointment.Subject;

            List<Telerik.Web.UI.Resource> s1s = e.Appointment.Resources.ToList();


            foreach (Telerik.Web.UI.Resource ss in s1s)
            {
                string text = ss.Text;
                resource = Convert.ToInt32(ss.Key);

            }


            if (e.Appointment.Subject == String.Empty)
            {
                e.Cancel = true;

            }


            else
            {

                string id = get.checkfroaddresid(Convert.ToInt32(addressid));

                if (id == "0")
                {

                    get.insert_appointment(start, end, name, resource, Convert.ToInt32(addressid));

                    Response.Redirect("~/FieldTech/ScheduleAppointment.aspx?addressid=" + addressid);
                }
                else
                {

                    string radalertscript = "<script language='javascript'>function f(){radalert('date allreday use', 330, 210); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);

                  

                }
            }


          
        }

 

Could someone explain me what am I doing wrong?
There are no errors. Just javascript code is not executed. I dont have alert() window on my screen.

 

On button click its show the popup but i wont show popup on RadScheduler1_AppointmentInsert() Resource Grouping Scheduler

i am also use the RadScriptBlock

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"><script>function MyFunction(){ alert('date');}</script></telerik:RadScriptBlock> but this also not working Please do the needfull ASAP

Regards

Aakash Lokhande

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 Mar 2018, 01:42 PM
Hi,

Add the registration of the RegisterStartupScript or RegisterClientScriptInclude methods in the Page_Load event and test again:

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "testOne", "MyFunction();", true);

or 

ScriptManager.RegisterClientScriptInclude(Page, Page.GetType(), "externalFile.js", "Script/externalFile.js");


Best regards,
Rumen
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Ajax
Asked by
aakash
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or