Reputation: 49
onselectionchanged
event i am passing the selected date to the textbox.What is the Issue? Its working fine when i add that user control at design time. But when i add it at run time in not working.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Dates.ascx.cs" Inherits="Date"%>
//created a public object named 'users' of control class
public partial class View_now : System.Web.UI.Page
{
public Control users;
}
//loaded the user control in page load event
protected void Page_Load(object sender, EventArgs e)
{
users = LoadControl("~\\Dates.ascx");
}
//applied the user control to a panel
protected void Button2_Click(object sender, EventArgs e)
{
Panel2.Controls.Add(users);
}
Now when i click the usercontrol's button,the click event doesn't fire.
Upvotes: 0
Views: 1602
Reputation: 13600
Add the controls during Page_Init() not Page_Load(). That should do the trick.
Upvotes: 1