Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 21st, 2003, 03:16 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
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)
    {
            InitializeComponent();
        base.OnInit(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);
cell.Controls.Add(ucActionControl);

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



Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.