Hi,
Can anyone help me to trigger dynamically loaded usercontrols click event?
What i did.........
Created User Control like One.ascx with one button
<%@ Control Language="C#" AutoEventWireup="false" CodeFile="one.ascx.cs" Inherits="one" %>
<asp:Label ID="Label1" runat="server" Text="Hello, this is My First User Control dynamically loaded :)"></asp:Label>
<asp:Button ID="btnShow" runat="server" Text="Show" OnClick="btnShow_Click" />
On Code behind
public void btnShow_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com");
}
In .aspx page, load above control by clicking button "First"
demo.aspx
<asp:Button ID="btnFirst" runat="server" Text="First" OnClick="btnFirst_Click" />
<asp:PlaceHolder ID="phModule" runat="server"></asp:PlaceHolder>
demo.aspx.cs
protected void btnFirst_Click(object sender, EventArgs e)
{
Control myUserControl = (Control)Page.LoadControl("controls/one.ascx");
phModule.Controls.Add(myUserControl);
}
Fail to redirect user to google.com by clicking button which written in .ascx file.
Kindly help