2010-07-09 65 views
0

我是telerik控件的新手。我正在將gridview升級到radgrid。使用updatepanel時出現Javascript錯誤

當我在asp:updatepanel控件中使用radgrid時,出現錯誤(請參閱圖像1.JPG)(http://www.freeimagehosting.net/image.php?a851a8525e.jpg)。我得到這個錯誤foreveryaction(如排序,篩選,編輯,行選擇,滾動)。任何人都可以幫助我如何解決這個問題。

我在radgrid中有一個linkbutton列。當我點擊按鈕,我得到錯誤(見圖2.JPG)(http://www.freeimagehosting.net/image.php?ebbdac443a.jpg)。如何在radgrid中做到這一點。當我點擊一個鏈接按鈕時,我只想拉sId,orderId和taskstatus。當我試圖做到這一點時,我得到了這個錯誤。請幫忙解決這個問題。

這裏是我的代碼

<asp:UpdatePanel ID="rg200UpdatePanel" runat="server"> 
        <ContentTemplate> 
         <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> 
         </telerik:RadScriptManager> 
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> 
          <ClientEvents OnRequestStart="onRequestStart" /> 
          <AjaxSettings> 
           <telerik:AjaxSetting AjaxControlID="rg200"> 
            <UpdatedControls> 
             <telerik:AjaxUpdatedControl ControlID="rg200" LoadingPanelID="RadAjaxLoadingPanel1" /> 
             <telerik:AjaxUpdatedControl ControlID="RadMenu1" /> 
            </UpdatedControls> 
           </telerik:AjaxSetting> 
           <telerik:AjaxSetting AjaxControlID="RadMenu1"> 
            <UpdatedControls> 
             <telerik:AjaxUpdatedControl ControlID="rg200" LoadingPanelID="RadAjaxLoadingPanel1" /> 
             <telerik:AjaxUpdatedControl ControlID="RadMenu1" /> 
            </UpdatedControls> 
           </telerik:AjaxSetting> 
          </AjaxSettings> 
         </telerik:RadAjaxManager> 
         <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"> 
         </telerik:RadAjaxLoadingPanel> 
         <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" /> 
         <telerik:RadGrid ID="rg200" runat="server" AutoGenerateColumns="False" PageSize="30" 
          Height="550px" Width="100%" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="True" 
          EnableHeaderContextMenu="True" GridLines="None" EnableHeaderContextFilterMenu="True" 
          AllowMultiRowEdit="true" AllowFilteringByColumn="True" OnPreRender="rg200_PreRender" 
          OnItemCreated="rg200_ItemCreated" EnableViewState="true" OnUpdateCommand="rg200_UpdateCommand" 
          AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" 
          OnPageIndexChanged="rg200_PageIndexChanged" OnItemCommand="rg216_ItemCommand"> 
          <HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White" 
           HorizontalAlign="Center" BorderColor="White" BorderWidth="1px" /> 
          <ExportSettings IgnorePaging="true" ExportOnlyData="true"> 
           <Pdf AllowModify="false" AllowPrinting="true" PageBottomMargin="" PageFooterMargin="" 
            PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin="" 
            PageWidth="14in" /> 
          </ExportSettings> 
          <MasterTableView GridLines="None" DataKeyNames="orderId" CommandItemDisplay="Top" 
           EditMode="EditForms"> 
           <CommandItemTemplate> 
            <div style="padding: 5px 5px;"> 
             <table> 
              <tr class="customFont"> 
               <td align="left"> 
                <b>Bulk Actions</b>  
               </td> 
               <td align="left"> 
                <asp:LinkButton ID="btnEditSelected" runat="server" OnClick="btnEditSelected_click" 
                 Visible='<%# rg200.EditIndexes.Count == 0 %>'>Edit Selected</asp:LinkButton> 

               </td> 
               <td align="left"> 
                <asp:LinkButton ID="btnUpdateEdited" runat="server" OnClick="btnUpdateEdited_click" 
                 Visible='<%# rg200.EditIndexes.Count > 0 %>'>Update Editing</asp:LinkButton> 

               </td> 
               <td align="left"> 
                <asp:LinkButton ID="btnCancel" runat="server" OnClick="btnCancel_click" Visible='<%# rg200.EditIndexes.Count > 0 || rg200.MasterTableView.IsItemInserted %>'>Cancel Editing</asp:LinkButton> 

               </td> 
               <td align="right"> 
                <img style="border: 0px; vertical-align: middle;" alt="" src="Images/AddRecord.gif" /> 
               </td> 
               <td align="left"> 
                <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !rg200.MasterTableView.IsItemInserted %>'>Add New Record</asp:LinkButton> 

               </td> 
               <td align="right"> 
                <img style="border: 0px; vertical-align: middle;" alt="" src="Images/Delete.gif" /> 
               </td> 
               <td align="left"> 
                <asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Delete all selected Records?')" 
                 runat="server" CommandName="DeleteSelected">Delete Selected</asp:LinkButton> 

               </td> 
               <td align="right"> 
                <img style="border: 0px; vertical-align: middle;" alt="" src="Images/Refresh.gif" /> 
               </td> 
               <td align="left"> 
                <asp:LinkButton ID="LinkButton4" runat="server" CommandName="Rebind">Refresh</asp:LinkButton> 

               </td> 
               <td align="left"> 
                <asp:ImageButton ID="ExportToWordButton" runat="server" ImageUrl="~/images/ExportToWord.gif" 
                 ToolTip="Export to Word" OnClick="ExportWord_Click" /> 

                <asp:ImageButton ID="ExportToExcelButton" runat="server" ImageUrl="~/images/ExportToExcel.gif" 
                 ToolTip="Export to Excel" OnClick="ExportExcel_Click" /> 

                <asp:ImageButton ID="ExportToPdfButton" runat="server" ImageUrl="~/images/ExportToPdf.gif" 
                 ToolTip="Export to Pdf" OnClick="ExportPdf_Click" /> 

                <asp:ImageButton ID="ExportToCsvButton" runat="server" ImageUrl="~/images/ExportToCsv.gif" 
                 ToolTip="Export to Csv" OnClick="ExportCsv_Click" /> 
               </td> 
              </tr> 
             </table> 
            </div> 
           </CommandItemTemplate> 
           <Columns> 
            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="3%" 
             ItemStyle-Width="3%"> 
             <HeaderStyle Width="3%"></HeaderStyle> 
             <ItemStyle Width="3%"></ItemStyle> 
            </telerik:GridClientSelectColumn> 
            <telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" ReadOnly="true" 
             Visible="false"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" Visible="false" 
             ReadOnly="true" DataField="orderId"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Customer Name" HeaderText="Customer Name" DataField="Customer Name" 
             ReadOnly="true"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Market Name" HeaderText="Market Name" DataField="Market Name" 
             ReadOnly="true"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="LOB" HeaderText="LOB" DataField="LOB" ReadOnly="true"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Headend Name" HeaderText="Headend Name" DataField="Headend Name" 
             ReadOnly="true"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Project Name" HeaderText="Project Name" DataField="Project Name" 
             ReadOnly="true"> 
            </telerik:GridBoundColumn> 
            <telerik:GridTemplateColumn UniqueName="Site Name" HeaderText="Site Name" DataField="SiteName" 
             ReadOnly="true"> 
             <ItemTemplate> 
              <asp:LinkButton ID="lnkSiteName" runat="server" Text='<%# Eval("Site Name") %>' 
               ForeColor="Blue" CommandName="sitename"></asp:LinkButton> 
             </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status" 
             ReadOnly="true"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr" 
             DataField="Clarify Account Nbr"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Site ID" HeaderText="Site ID" DataField="Site ID"> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn UniqueName="Quote ID" HeaderText="Quote ID" DataField="Quote ID"> 
            </telerik:GridBoundColumn> 
            <telerik:GridCheckBoxColumn UniqueName="EDP Created?" HeaderText="EDP Created?" DataField="EDP Created?"> 
            </telerik:GridCheckBoxColumn> 
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" Visible="false" Display="false"> 
            </telerik:GridEditCommandColumn> 
           </Columns> 
           <EditFormSettings EditFormType="Template"> 
            <FormTemplate> 
             <table id="Table1" cellspacing="1" cellpadding="1"> 
              <tr> 
               <td> 
                <telerik:RadTabStrip runat="server" ID="RadTabStrip1" Orientation="HorizontalTop" 
                 SelectedIndex="0" MultiPageID="RadMultiPage1"> 
                 <Tabs> 
                  <telerik:RadTab Text="Task Data" PageViewID="RadPageView1"> 
                  </telerik:RadTab> 
                  <telerik:RadTab Text="Notes" PageViewID="RadPageView2"> 
                  </telerik:RadTab> 
                 </Tabs> 
                </telerik:RadTabStrip> 
                <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0"> 
                 <telerik:RadPageView runat="server" ID="RadPageView1"> 
                  <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module"> 
                   <tr> 
                    <td> 
                    </td> 
                    <td> 
                    </td> 
                   </tr> 
                   <tr> 
                    <td> 
                     Clarify Account Nbr: 
                    </td> 
                    <td> 
                     <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Clarify Account Nbr") %>'> 
                     </asp:TextBox> 
                    </td> 
                   </tr> 
                   <tr> 
                    <td> 
                     Site ID: 
                    </td> 
                    <td> 
                     <asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("Site ID") %>' TabIndex="1"> 
                     </asp:TextBox> 
                    </td> 
                   </tr> 
                   <tr> 
                    <td> 
                     Quote ID: 
                    </td> 
                    <td> 
                     <asp:TextBox ID="TextBox3" runat="server" Text='<%# Eval("Quote ID") %>' TabIndex="2"> 
                     </asp:TextBox> 
                    </td> 
                   </tr> 
                   <tr> 
                    <td> 
                     EDP Created?: 
                    </td> 
                    <td> 
                     <asp:CheckBox ID="CheckBox1" runat="server" Text='<%# Eval("EDP Created?") %>' TabIndex="3"> 
                     </asp:CheckBox> 
                    </td> 
                   </tr> 
                   <tr> 
                    <td align="right" colspan="2"> 
                     <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                      runat="server" CommandName='Update'></asp:Button> 
                     <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" 
                      CommandName="Cancel"></asp:Button> 
                    </td> 
                   </tr> 
                  </table> 
                 </telerik:RadPageView> 
                 <telerik:RadPageView runat="server" ID="RadPageView2"> 
                 </telerik:RadPageView> 
                </telerik:RadMultiPage> 
               </td> 
              </tr> 
             </table> 
            </FormTemplate> 
           </EditFormSettings> 
          </MasterTableView> 
          <ClientSettings EnableRowHoverStyle="true" ReorderColumnsOnClient="false" AllowDragToGroup="false" 
           AllowColumnsReorder="True"> 
           <Scrolling AllowScroll="true" EnableVirtualScrollPaging="false" UseStaticHeaders="true" /> 
           <Selecting AllowRowSelect="true"></Selecting> 
           <Resizing AllowRowResize="true" AllowColumnResize="True" EnableRealTimeResize="True" 
            ResizeGridOnColumnResize="False"></Resizing> 
           <ClientEvents OnRowContextMenu="RowContextMenu" OnRowDblClick="RowDblClick"></ClientEvents> 
          </ClientSettings> 
          <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle> 
         </telerik:RadGrid> 
        </ContentTemplate> 
       </asp:UpdatePanel> 

.cs文件

protected void rg216_ItemCommand(object source, GridCommandEventArgs e) 
{ 
    try 
    { 
     if (e.CommandName.ToLower() == "sitename") 
     { 
      GridViewRow rw = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); 
      Label lblsId = (Label)rw.FindControl("lblsId"); 
      Label lblorderId = (Label)rw.FindControl("lblorderId"); 
      Label lblTaskStatus = (Label)rw.FindControl("lblTaskStatus"); 
      //Label lblsId = (Label)e.Item.FindControl("lblsId"); 
      //Label lblorderId = (Label)e.Item.FindControl("lblorderId"); 
      //Label lblTaskStatus = (Label)e.Item.FindControl("lblTaskStatus"); 
      Session["selorderID"] = lblorderId.Text.Trim(); 
      Session["selsID"] = lblsId.Text; 
      Session["selTaskStatus"] = lblTaskStatus.Text; 
      ScriptManager.RegisterClientScriptBlock(this.rg200UpdatePanel, this.GetType(), "strSearSiteName", "document.getElementById('ctl00_PagePlaceholder_ifrmPopups').src='OrdDet.aspx'", true); 
      ScriptManager.RegisterClientScriptBlock(this.rg200UpdatePanel, this.GetType(), "open", "openpopup()", true); 
      ifrmPopups.Style.Add("height", "409px"); 
      LinkButton lnkSiteName = (LinkButton)rw.FindControl("lnkSiteName"); 
     } 
    } 
    catch (Exception ex) 
    { 
     throw ex; 
    } 
} 

回答

0

移動所有Telerik控制的MS的UpdatePanel的外面,僅僅使用AJAX他經理ajaxify他們。在更新面板中放置RadScriptManager或asp ScriptManager也不正確。

迪克