Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 21st, 2003, 03:16 PM
Registered User
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fire WebForm Method from User Control

Basically, I would like to utilize a button inside a user control to fire a method in the parent WebForm. The code compiles, but the event never gets fired.

My User Control class is as follows:
public class ActionControl : System.Web.UI.UserControl
    protected System.Web.UI.WebControls.DropDownList ddlActions;
    protected System.Web.UI.WebControls.Button btnGo;
    public delegate void GoClickedHandler(object sender, EventArgs e);
    public event GoClickedHandler GoClicked;

    private void Page_Load(object sender, System.EventArgs e)

    public DropDownList Actions
        get { return this.ddlActions; }

    public Button Go
        get { return this.btnGo; }

    public void OnGoClicked(object sender, System.EventArgs e)
        GoClicked(this, e);

    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)

    private void InitializeComponent()
        this.btnGo.Click += new System.EventHandler(this.OnGoClicked);
        this.Load += new System.EventHandler(this.Page_Load);


Then I have the following code to utilize the button in my WebForm:

ucActionControl = (ActionControl)this.LoadControl("../UserControls/ActionControl.ascx");
ucActionControl.GoClicked += new ActionControl.GoClickedHandler(this.Go_Click);

private void Go_Click(object sender, EventArgs e)
Response.Write ("EVENT IS FIRING");

Similar Threads
Thread Thread Starter Forum Replies Last Post
CustomValidator won't fire method cridley General .NET 4 August 4th, 2009 05:37 AM
Web User Control to act on interface shared method rodmcleay General .NET 0 June 4th, 2008 11:51 PM
Windows Form Control In WebForm windows_mss ASP.NET 1.0 and 1.1 Professional 0 January 25th, 2007 02:16 AM
Webform listbox control databing to any property Rachel P Classic ASP Basics 2 October 1st, 2005 10:01 PM
VB Data Control - Reposition does not fire georg Pro VB 6 2 September 8th, 2003 07:32 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.