Hi,
i am new to telerik. I have built a user control with the following code:
When i put it in a content tag in my html code it works fine. But i would like to add the control via a click on a button.
So on the page where the button is located i wrote the following in the code behind:
Has anybody an idea why this doesn't work or a solution so ajax functionality will be enabled for this purpose?
Thanks
Simon
i am new to telerik. I have built a user control with the following code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" Codebehind="WebUserControl.ascx.cs" ClassName="WebUserControl" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager><asp:SqlDataSource ID="GridSource" runat="server" ConnectionString="<%$ ConnectionStrings:Test%>" SelectCommand="SELECT * FROM Evt"> </asp:SqlDataSource><telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="GridSource" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" ShowGroupPanel="True"> <ClientSettings AllowDragToGroup="True"> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings> <MasterTableView> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"></FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu></telerik:RadGrid> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager>So on the page where the button is located i wrote the following in the code behind:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class SiteMaster : System.Web.UI.MasterPage{ WebUserControl ctrl; protected void Page_Load(object sender, EventArgs e) { Button BTN1 = new Button(); BTN1.Click += new EventHandler(BTN_Click); this.MenuContent.Controls.Add(BTN1); } protected void BTN_Click(object sender, EventArgs e) { ctrl = (WebUserControl)LoadControl("~/WebUserControl.ascx"); this.MenuContent.Controls.Add(ctrl); }}Thanks
Simon