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

Error: $get("TargetSlotHiddenField") is null

4 Answers 71 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Farshad heidary
Top achievements
Rank 1
Farshad heidary asked on 10 Feb 2010, 07:08 AM
hi guys and support team.
i response this error when i drag drop task into schaduler.(dargDrop Schaduler)
what  my problem?
how i can fix it?

tnx

4 Answers, 1 is accepted

Sort by
0
Farshad heidary
Top achievements
Rank 1
answered on 10 Feb 2010, 07:19 AM
i test "<%= TargetSlotHiddenField.ClientID %>" but i recive this error:
Error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.
Source File: http://localhost/IFarshadDotIR/ScriptResource.axd?d=klIR8V_JJaMWoZwdawncxFo8WLDFm0CB58kHqNTypAzeKI61YqJmF171GvgmP2EBFlInwpilgTVeu04xyGMD6tn9twhhV-_C_wBL3PaAZfY1&t=634321714550625000
Line: 5
0
Vesko
Top achievements
Rank 2
answered on 12 Feb 2010, 02:50 PM
Do you have a hidden field called TargetSlotHiddenField on your page like in the demo?
0
Nick
Top achievements
Rank 1
answered on 25 May 2010, 08:47 PM
I have the <input type="hidden" runat="server" if="TargetSlotHiddenField"/> in my usercontrol and I still get this error

The drag and drop does not insert it when dropped in the calendar above

    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
        <script type="text/javascript"
 
 
            function rowDropping(sender, eventArgs) { 
                // Fired when the user drops a grid row 
                var htmlElement = eventArgs.get_destinationHtmlElement(); 
                var scheduler = $find('<%= RadScheduler1.ClientID %>'); 
 
                if (isPartOfSchedulerAppointmentArea(htmlElement)) { 
                    // The row was dropped over the scheduler appointment area 
                    // Find the exact time slot and save its unique index in the hidden field 
                    var timeSlot = scheduler._activeModel.getTimeSlotFromDomElement(htmlElement); 
 
                    $get("TargetSlotHiddenField").value = timeSlot.get_index(); 
 
                    // The HTML needs to be set in order for the postback to execute normally 
                    eventArgs.set_destinationHtmlElement("TargetSlotHiddenField"); 
                } 
                else { 
                    // The node was dropped elsewhere on the document 
                    eventArgs.set_cancel(true); 
                } 
            } 
 
            function isPartOfSchedulerAppointmentArea(htmlElement) { 
                // Determines if an html element is part of the scheduler appointment area 
                // This can be either the rsContent or the rsAllDay div (in day and week view) 
                return $telerik.$(htmlElement).parents().is("div.rsAllDay") || 
                            $telerik.$(htmlElement).parents().is("div.rsContent") 
            } 
 
            function onRowDoubleClick(sender, args) { 
                sender.get_masterTableView().editItem(args.get_itemIndexHierarchical()); 
            } 
        </script> 
    </telerik:RadScriptBlock> 
     
    <input type="hidden" runat="server" id="TargetSlotHiddenField" /> 
 
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadScheduler1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadSplitter runat="server" ID="RadSplitter1" Height="552px" Width="880px" 
        CssClass="exampleContainer" Orientation="Horizontal" Skin="Office2007"
        <telerik:RadPane runat="server" ID="TopPane" Height="400px" Scrolling="None"
            <telerik:RadScheduler ID="RadScheduler1" runat="server" Width="100%" DataSourceID="SchedulerDataSource" 
                DataKeyField="AppointmentID" DataStartField="Start" DataEndField="End" DataSubjectField="Subject" 
                OnAppointmentCommand="RadScheduler1_AppointmentCommand" Skin="Office2007" Height="100%" 
                ShowFooter="false" RowHeaderWidth="52" CustomAttributeNames="Due, Priority" OverflowBehavior="Scroll"
                <AdvancedForm Modal="true" /> 
                <AppointmentTemplate> 
                    <%# Eval("Subject") %> 
                    <asp:Button runat="server" ID="UnscheduleAppointment" CssClass="simpleButton" CommandName="Unschedule" 
                        Text="&nbsp;" ToolTip="Unschedule this appointment" /> 
                </AppointmentTemplate> 
                <TimeSlotContextMenuSettings EnableDefault="true" /> 
                <AppointmentContextMenuSettings EnableDefault="true" /> 
            </telerik:RadScheduler> 
        </telerik:RadPane> 
        <telerik:RadSplitBar runat="Server" ID="RadSplitBar1" /> 
        <telerik:RadPane runat="server" ID="BottomPane"
            <div style="float: left; height: 100%; width: 55px; background: #E3EFFF; text-align: center; 
                border-right: 1px solid #6593CF;"> 
                <img src="../images/tasks.gif" alt="" /></div
            <div style="margin-left: 56px; border: none;"
                <telerik:RadGrid runat="server" ID="RadGrid1" DataSourceID="GridDataSource" GridLines="None" 
                    AutoGenerateColumns="False" OnRowDrop="RadGrid1_RowDrop" Skin="Office2007" Style="border: none; 
                    outline: 0" Height="100%" AllowAutomaticInserts="True" AllowAutomaticUpdates="true" 
                    ShowFooter="true" OnItemCreated="RadGrid1_ItemCreated" OnItemCommand="RadGrid1_ItemCommand" 
                    AllowSorting="true"
                    <ClientSettings AllowRowsDragDrop="True"
                        <Selecting AllowRowSelect="True" /> 
                        <ClientEvents OnRowDropping="rowDropping" OnRowDblClick="onRowDoubleClick" /> 
                    </ClientSettings> 
                    <MasterTableView DataKeyNames="AppointmentID" InsertItemDisplay="Bottom" EditMode="InPlace"
                        <SortExpressions> 
                            <telerik:GridSortExpression FieldName="Due" SortOrder="Ascending" /> 
                        </SortExpressions> 
                        <Columns> 
                            <telerik:GridTemplateColumn DataField="Subject" HeaderText="Task"
                                <ItemTemplate> 
                                    <asp:Label runat="server" ID="Label1" Text='<%# Bind("Subject") %>'></asp:Label> 
                                </ItemTemplate> 
                                <FooterTemplate> 
                                    <asp:LinkButton Text="Add new task" CommandName="<%# RadGrid.InitInsertCommandName %>" 
                                        runat="server" ID="LinkButton1"></asp:LinkButton> 
                                </FooterTemplate> 
                                <EditItemTemplate> 
                                    <asp:TextBox runat="Server" ID="TextBox1" Text='<%# Bind("Subject") %>' Width="100%"></asp:TextBox> 
                                </EditItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridDateTimeColumn DataField="Due" HeaderText="Due Date" DataFormatString="{0:d}" 
                                HeaderStyle-Width="200px"
                            </telerik:GridDateTimeColumn> 
                            <telerik:GridTemplateColumn DataField="Priority" HeaderText="Priority" HeaderStyle-Width="200px"
                                <ItemTemplate> 
                                    <asp:Label runat="Server" ID="Label2" Text='<%#Bind("Priority") %>'></asp:Label> 
                                </ItemTemplate> 
                                <EditItemTemplate> 
                                    <telerik:RadComboBox runat="server" ID="priorityComboBox" SelectedValue='<%#Bind("Priority") %>' 
                                        Skin="Office2007" Width="80px"
                                        <Items> 
                                            <telerik:RadComboBoxItem Text="High" Value="High" /> 
                                            <telerik:RadComboBoxItem Text="Medium" Value="Medium" /> 
                                            <telerik:RadComboBoxItem Text="Low" Value="Low" /> 
                                        </Items> 
                                    </telerik:RadComboBox> 
                                    <asp:LinkButton ID="btnUpdate" Text="Save" runat="server" CommandName='<%# IIf(TypeOf Container Is GridDataInsertItem, RadGrid.PerformInsertCommandName, RadGrid.UpdateCommandName) %>'></asp:LinkButton> 
                                    <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName='<%# RadGrid.CancelCommandName %>'></asp:LinkButton> 
                                </EditItemTemplate> 
                            </telerik:GridTemplateColumn> 
                        </Columns> 
                    </MasterTableView> 
                </telerik:RadGrid> 
            </div> 
        </telerik:RadPane> 
    </telerik:RadSplitter> 
 
<asp:SqlDataSource ID="SchedulerDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:portal %>" 
    SelectCommand="SELECT [AppointmentID], [Start], [End], [Subject], [Due], [Priority]  FROM [Appointments] WHERE ([Start] IS NOT NULL) AND ([End] IS NOT NULL)" 
    InsertCommand="INSERT INTO [Appointments] ([Subject], [Start], [End]) VALUES (@Subject, @Start, @End)" 
    UpdateCommand="UPDATE [Appointments] SET [Start] = @Start, [End] = @End, [Subject] = @Subject WHERE AppointmentID = @AppointmentID" 
    DeleteCommand="DELETE FROM [Appointments] WHERE [AppointmentID] = @AppointmentID"
    <InsertParameters> 
        <asp:Parameter Name="Subject" Type="String" /> 
        <asp:Parameter Name="Start" Type="DateTime" /> 
        <asp:Parameter Name="End" Type="DateTime" /> 
    </InsertParameters> 
    <UpdateParameters> 
        <asp:Parameter Name="Subject" Type="String" /> 
        <asp:Parameter Name="Start" Type="DateTime" /> 
        <asp:Parameter Name="End" Type="DateTime" /> 
        <asp:Parameter Name="AppointmentID" Type="Int32" /> 
    </UpdateParameters> 
    <DeleteParameters> 
        <asp:Parameter Name="AppointmentID" Type="Int32" /> 
    </DeleteParameters> 
</asp:SqlDataSource> 
<asp:SqlDataSource ID="GridDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:portal %>" 
    SelectCommand="SELECT [AppointmentID], [Start], [End], [Subject], [Due], [Priority] FROM [Appointments] WHERE ([Start] IS NULL) AND ([End] IS NULL)" 
    UpdateCommand="UPDATE [Appointments] SET [Start] = @Start, [End] = @End, [Subject] = @Subject, [Due] = @Due, [Priority] = @Priority WHERE AppointmentID = @AppointmentID" 
    InsertCommand="INSERT INTO [Appointments] ([Subject], [Due], [Priority]) VALUES (@Subject, @Due, @Priority)"
    <UpdateParameters> 
        <asp:Parameter Name="Subject" Type="String" /> 
        <asp:Parameter Name="Start" Type="DateTime" /> 
        <asp:Parameter Name="End" Type="DateTime" /> 
        <asp:Parameter Name="Due" Type="DateTime" /> 
        <asp:Parameter Name="Priority" Type="String" /> 
        <asp:Parameter Name="AppointmentID" Type="Int32" /> 
    </UpdateParameters> 
    <InsertParameters> 
        <asp:Parameter Name="Subject" Type="String" /> 
        <asp:Parameter Name="Due" Type="DateTime" /> 
        <asp:Parameter Name="Priority" Type="String" /> 
    </InsertParameters> 
</asp:SqlDataSource> 
 

0
Peter
Telerik team
answered on 28 May 2010, 11:50 AM
Hi Ty,

Since you use a user control, the client ID of the hidden field is modified. You need to get it from the server with the following code:

$get('<%=TargetSlotHiddenField.ClientID %>').value = timeSlot.get_index();

Greetings,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Scheduler
Asked by
Farshad heidary
Top achievements
Rank 1
Answers by
Farshad heidary
Top achievements
Rank 1
Vesko
Top achievements
Rank 2
Nick
Top achievements
Rank 1
Peter
Telerik team
Share this question
or