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

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

1 Answer 111 Views
Button
This is a migrated thread and some comments may be shown as answers.
Gary Meagher
Top achievements
Rank 1
Gary Meagher asked on 18 Nov 2010, 08:32 PM
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);
        }
    }
    #endregion
 
    protected void gridProductSubs_ItemCreated(object sender, GridItemEventArgs e)
    {
        CreateLinks(e, SubsEntity.ResearchProduct);
    }
<telerik:GridTemplateColumn UniqueName="Remove">
                    <ItemTemplate>
                        <asp:Button ID="btnRemove" runat="server" CausesValidation="False"
                            ToolTip="Remove" Text="Remove" />
                    </ItemTemplate>
                    <HeaderStyle Width="35px" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="Edit">
                    <ItemTemplate>
                        <asp:Button ID="btnEdit" runat="server" CausesValidation="False"
                            ToolTip="Edit" Text="Edit" />
                    </ItemTemplate>
                    <HeaderStyle Width="35px" />
                    </telerik:GridTemplateColumn>

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 23 Nov 2010, 12:38 PM
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,
Pero
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.
Tags
Button
Asked by
Gary Meagher
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or