Changing from asp Button to RadButton generate javascript errors within a RadGrid

2 posts, 0 answers
  1. Gary Meagher
    Gary Meagher avatar
    29 posts
    Member since:
    Jan 2010

    Posted 18 Nov 2010 Link to this post

    In the following code, if I change Button to RadButton I'm getting all sorts of javascript exceptions from Telerik internal code.

    private void CreateLinks(GridItemEventArgs e, SubsEntity type)
            if (e.Item is GridDataItem && e.Item.ItemIndex != -1)
                Button editLink = (Button)e.Item.FindControl("btnEdit");
                //editLink.PostBackUrl = "ManageSubscriptions.aspx?EditMode=true&Type=" + type + "&SubscriptionID=" + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["SubscriptionID"];
                editLink.PostBackUrl = UIMgr.GetEditSubscriptionURL(this.DataSet, type, e.Item.ItemIndex);
                Button removeLink = (Button)e.Item.FindControl("btnRemove");
                removeLink.Attributes["href"] = "#";
                removeLink.Attributes["onclick"] = String.Format("return ShowConfirmForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["SubscriptionID"], e.Item.ItemIndex);
        protected void gridProductSubs_ItemCreated(object sender, GridItemEventArgs e)
            CreateLinks(e, SubsEntity.ResearchProduct);
    <telerik:GridTemplateColumn UniqueName="Remove">
                            <asp:Button ID="btnRemove" runat="server" CausesValidation="False"
                                ToolTip="Remove" Text="Remove" />
                        <HeaderStyle Width="35px" />
                        <telerik:GridTemplateColumn UniqueName="Edit">
                            <asp:Button ID="btnEdit" runat="server" CausesValidation="False"
                                ToolTip="Edit" Text="Edit" />
                        <HeaderStyle Width="35px" />

  2. Pero
    Pero avatar
    1156 posts

    Posted 23 Nov 2010 Link to this post

    Hello Gary,

    I think the problem is caused by the fact that you set the "onclick" and "href" attributes of the RadButton control. You should use the OnClientClicked property (clicked client-side event) for this purpose.
    Could you please provide the ShowConfirmForm JavaScript function? Once I know the code executed when the button is clicked, I can suggest how to change your code so that the problems are avoided.

    Sincerely yours,
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. DevCraft R3 2016 release webinar banner
Back to Top