I have a user control that contains a RadGrid with the EditLink column,
and the onClick code is generated in the code-behind file,
but whenever I click on the EditLink hyperlink I get the Microsoft JScript runtime error: Object expected exception.
My default.aspx RadScriptManager code,
any help will be appreciated.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Prospects.ascx.cs" Inherits="Prospects" %> <telerik:RadCodeBlock ID="radcodeProspects" runat="server"> <script type="text/javascript"> function ShowEditForm(id, rowIndex) { alert(id); window.radopen("EditContact.aspx?ContactID=" + id, "UserListDialog"); return false; } function ShowInsertForm() { window.radopen("EditContact.aspx", "UserListDialog"); return false; } function refreshGrid(arg) { if (!arg) { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); } else { $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate"); } } </script> </telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="prospectGrid" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="prospectGrid"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="prospectGrid" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadGrid AllowSorting="true" BackColor="#393939" ID="prospectGrid" runat="server" AllowPaging="true" PageSize="15" Width="980px" CssClass="productsGrid" OnPreRender="prospectGrid_PreRender" OnItemCreated="prospectGrid_ItemCreated" OnNeedDataSource="prospectGrid_NeedDataSource" style="outline:0"> <MasterTableView AutoGenerateColumns="false" PagerStyle-Mode="NextPrevAndNumeric" AllowFilteringByColumn="false" DataKeyNames="OrderID" ClientDataKeyNames="OrderID" TableLayout="Fixed"> <Columns> <telerik:GridBoundColumn DataField="OrderID" HeaderText="ProspectID" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderStyle-Width="70px" FilterControlWidth="35px"> </telerik:GridBoundColumn> <telerik:GridNumericColumn DataField="Freight" HeaderText="Freight" DataFormatString="{0:c}" HeaderStyle-Width="110px" FilterControlWidth="60px"> </telerik:GridNumericColumn> <telerik:GridBoundColumn DataField="ShipName" HeaderText="Prospect Name" HeaderStyle-Width="300px" FilterControlWidth="260px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="Country" FilterControlWidth="70px"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="Order Date" DataFormatString="{0:d}" FilterControlWidth="95px"> </telerik:GridDateTimeColumn> <telerik:GridDateTimeColumn DataField="ShippedDate" HeaderText="Shipping Date" DataFormatString="{0:d}" FilterControlWidth="95px"> </telerik:GridDateTimeColumn> <telerik:GridTemplateColumn UniqueName="TemplateEditColumn"> <ItemTemplate> <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <ClientSettings AllowDragToGroup="false" EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="360px" /> </ClientSettings> </telerik:RadGrid> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"> <Windows> <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="320px" Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" /> </Windows> </telerik:RadWindowManager> <telerik:RadAjaxLoadingPanel ID="ProductsLoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>and the onClick code is generated in the code-behind file,
protected void prospectGrid_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink"); editLink.Attributes["href"] = "#"; editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"], e.Item.ItemIndex); } } protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { if (e.Argument == "Rebind") { prospectGrid.MasterTableView.SortExpressions.Clear(); prospectGrid.MasterTableView.GroupByExpressions.Clear(); prospectGrid.Rebind(); } else if (e.Argument == "RebindAndNavigate") { prospectGrid.MasterTableView.SortExpressions.Clear(); prospectGrid.MasterTableView.GroupByExpressions.Clear(); prospectGrid.MasterTableView.CurrentPageIndex = prospectGrid.MasterTableView.PageCount - 1; prospectGrid.Rebind(); } }but whenever I click on the EditLink hyperlink I get the Microsoft JScript runtime error: Object expected exception.
My default.aspx RadScriptManager code,
<telerik:RadScriptManager runat="server" ID="RadScriptManager1"> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Path="~/Scripts/jquery.maphilight.min.js" /> <asp:ScriptReference Path="~/Scripts/maphilight.js" /> </Scripts> </telerik:RadScriptManager>any help will be appreciated.