Click here to Skip to main content
15,913,296 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a webpage, that content of witch i divided into namespaces containing different usercontrols.

On my default page i would like to dynamically add OnClick events to my loaded user controls, i tried this way:

C#
using MyWebSite.CONTROL;

namespace MyWebSite
{

    public partial class _Default : System.Web.UI.Page
    {
        

        Navigation Navy;
        private void Create_MainTable()
        {

            Navy = (Navigation)LoadControl("~/CONTROL/Navigation.ascx");

            Navy.BtnHello.OnClientClick += new EventHandler(BtnHello_Click);
            
            
            MainPanelOnMySite.Controls.Add(Navy);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.Create_MainTable();

            }
            
        }

 
        protected void BtnHello_Click(object sender, EventArgs e)
        {
            Navy.BtnHello.Text = "HELLO WORLD";
        }
}



Unfortunately my OnClick event does not work, what can i do ?
Posted
Comments
me.ajaykumar 4-Sep-13 7:30am    
Navy.BtnHello.OnClientClick += new EventHandler(BtnHello_Click);
instead of this try
Navy.BtnHello.OnClick += new EventHandler(BtnHello_Click);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900