Apr 16, 2009, 10:27 AM
[CLOSED] Load ASCX control from AjaxEvent
Hi, How can I load ASCX usercontrol from AjaxEvent?
I want to do this in the AjaxEvent :
The WebuserControl.aspx
Default.aspx
I want to do this in the AjaxEvent :
protected void Button1_Click(object sender, AjaxEventArgs e)
{
string currentUc = "~/WebUserControl1.ascx";
var uc = Page.LoadControl(currentUc);
Window1.BodyControls.Clear();
Window1.BodyControls.Add(uc);
Window1.Show();
}
The WebuserControl.aspx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"
Inherits="WebApplication1.WebUserControl1" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<ext:Panel ID="Panel1" runat="server" Frame="true" Title="Label Style and Separator"
Width="250">
<Body>
<ext:FormLayout ID="FormLayout1" runat="server" LabelSeparator="-" LabelStyle="color:red;"
LabelWidth="55">
<ext:Anchor Horizontal="95%">
<ext:TextField ID="TextField1" runat="server" FieldLabel="Label">
</ext:TextField>
</ext:Anchor>
<ext:Anchor Horizontal="95%">
<ext:TextField ID="TextField2" runat="server" FieldLabel="Label" LabelStyle="color:blue;"
LabelSeparator="+">
</ext:TextField>
</ext:Anchor>
</ext:FormLayout>
</Body>
</ext:Panel>
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<ext:Button ID="Button1" runat="server" Text="Show">
<ajaxevents>
<Click OnEvent="Button1_Click">
</Click>
</ajaxevents>
</ext:Button>
<ext:Window ID="Window1" runat="server" Icon="Group" Title="Window1" Width="400"
Height="400" AutoShow="false" Modal="true" Showonload="false">
<body>
</body>
<buttons>
<ext:Button ID="SaveButton" runat="server" Text="Save" Icon="Disk">
</ext:Button>
<ext:Button ID="CancelButton" runat="server" Text="Cancel" Icon="Cancel">
<Listeners>
<Click Handler="#{Window1}.hide()" />
</Listeners>
</ext:Button>
</buttons>
</ext:Window>
</form>
</body>
</html>