CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 7/7/2005 5:50:19 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 21 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
mxmissile
Asp.Net User
Building a Custom Control7/7/2005 5:50:19 PM

0/0

I am trying to build a simple control based off a PlaceHolder.  When I drop this on a webform, it renders correctly but my event does not fire.  At a glance can anyone see what is wrong?

using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyControls

    public class TestButtons : System.Web.UI.WebControls.PlaceHolder
   { 
      public TestButtons() : base() {} 
      public delegate void ClickHandler(object sender,ClickResponse response); 

      [ Description("Fires when a button is clicked."), Category("Action"), Bindable(true) ] 
      public event ClickHandler OnClick; 

      public override ControlCollection Controls { get { EnsureChildControls(); return base.Controls; } } 
      
      private void btnOk_Click(Object sender, EventArgs e) { this.OnClick(sender,ClickResponse.Ok); } 

     private void btnCancel_Click(Object sender, EventArgs e) { this.OnClick(sender,ClickResponse.Cancel); } 

     private Literal Spacer() { Literal lit = new Literal(); lit.Text = "  "; return lit; } 

      protected override void CreateChildControls()
      { 
         System.Web.UI.WebControls.Button b = new Button(); 
         b.Text = "Ok"; 
         b.Width = 60; 
         b.Click += new EventHandler(btnOk_Click); 
         this.Controls.Add(b); 
         this.Controls.Add(Spacer()); 
         
         b = new Button(); 
         b.Text = "Cancel"; 
         b.Width = 60; 
         b.Click += new EventHandler(btnCancel_Click); 
         this.Controls.Add(b);
         this.Controls.Add(Spacer());

         base.CreateChildControls(); 
      } 
      
      public enum ClickResponse { Ok, Cancel } } }
http://www.heliosfx.com
Raterus
Asp.Net User
Re: Building a Custom Control7/7/2005 6:24:48 PM

0/0

Try setting an id on both of the button's, sometimes this can have a big effect if you don't.
http://scottonwriting.net/sowblog/posts/3962.aspx


Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. Luke 11:9
mxmissile
Asp.Net User
Re: Building a Custom Control7/7/2005 7:49:46 PM

0/0

I just added unique string IDs to both buttons.  Changed the OnClick handler to just Click.  Still wont fire.
http://www.heliosfx.com
billrob458
Asp.Net User
Re: Building a Custom Control7/8/2005 6:57:03 PM

0/0

I really wasn't able to determine why you events weren't firing, but I did come up with a fix.

protected override void OnLoad(EventArgs e)
{
 EnsureChildControls();
 base.OnLoad (e);
}


In the load method of the your control you should call EnsureChildControls.  The only thing I could figure is I know the Framework calls EnsureChildControls during the PreRender event of the page.  (during the InteralPreRenderRecursive call).  This might be too late a time to fire events off, of perhaps the framework doesn't event check for events this late in the lifecycle.  (I am really not sure, I am just making that part up.)

bill

4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Visual Basic 2005 Programmer's Reference Authors: Rod Stephens, Pages: 1022, Published: 2005
Pro ASP. Net 3. 5 Server Controls and AJAX Components Authors: Rob Cameron, Dale Michalk, Pages: 740, Published: 2008
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2005
Programming Visual Basic 2005 Authors: Jesse Liberty, Pages: 548, Published: 2005
Microsoft Sharepoint: Building Office 2007 Solutions in C# 2005 Authors: Scot Hillier, Pages: 513, Published: 2007
The Complete Idiot's Guide to Buying and Selling a Home Authors: Shelley O'Hara, Nancy D. Lewis, Pages: 432, Published: 2003
Pro VB 2008 and the .NET 3.5 Platform Authors: Andrew Troelsen, Pages: 1377, Published: 2008

Web:
15 Seconds : Creating a Web Custom Control James Culshaw shares his experiences building his first working custom control, a basic mask control that allows input of time values, and offers advice and ...
Coding4Fun : Who Is Looking: Building a Custom ASP.NET Control ... In this article, Stephen Walther shows you how to create a custom ASP.NET control that uses Javascript, Cascading Style Sheets, and Ajax to display a list ...
Building a Complex Custom Control: Rolodex | O'Reilly Media Jul 11, 2005 ... Jesse Liberty shows you how to create a complex Windows custom control for .NET 2.0, or Visual Studio 2005.
Building the Custom Server Control Examples This topic describes how to compile the custom control examples into an assembly and use the controls in ASP.NET Web pages. It also describes how you can ...
Building a Full-Featured Custom DataGrid Control - developerFusion ... In this article, we will demonstrate how you can build your very own Datagrid control component, one that you will be able to customize, ...
Building a Custom Validator Control - Part 1 Well, the DotNetJunkies are at it again. We are starting our next book on building custom .NET server controls. So to follow with this category I'll be ...
Building a Custom Registration and Login Control Building a Custom Registration and Login Control. G. Andrew Duthie Graymad Enterprises, Inc. January 2004. Applies to: Microsoft® ASP.NET ...
John's Blog | XPages Example: Building a Custom Control - How to ... XPages Example: Building a Custom Control - How to build a Custom Multi- FileUpload Control that you can drop on any XPage, and it stores all attachments in ...
15 Seconds : Building ASP.NET User and Server Controls, Part 2 This is very similar to adding a user control to the page (See Building ASP.NET User and Custom Controls, Part 1). These tag values will be automatically ...
Custom Server Controls - ASP.NET Forums Microsoft’s Joe Stagner recommends the following books on building custom server controls. Professional ASP.NET 2.0 Server Control and Component Development ...

Videos:
Building your own custom computer Part 1 Custom computer Things you will need- Case Motherboard C.P.U Heatsink Thermal Compound Hard Drive/s R.A.M Power Supply Video Card Operating System (...
[TBA] Episode Two - Custom Controls In the second episode of The Blue Alliance, we show you how to build your own custom controls to control a FIRST robot. Also, we show you how to modi...
How Tidewater Custom Modular Homes manufactures custom modular homes Why is off-site, stick-built home construction better? With a 120,000 sq. ft. climate controlled facility, a dedicated work force and thoroughly eng...
building your own custom computer part II (2) custom computer
building your own custom computer Part III (3) custom computer
MODx 0.9.5 PHP Application Framework. Ajax CMS. SEO CMS MODx is an open source PHP Application Framework that helps you take control of your online content. It empowers developers and advanced users to giv...
Building your own custom computer Last Part Custom computer
Cisco Wireless Control System Video Data Sheet Learn more about the Cisco Wireless Control System - the industry's leading management platform for WLAN planning, configuration, monitoring and trou...
FlightCheck: Ground Controls Part 2 Ground Controls Part 2 Building a custom Ground Control set based on an existing set within your FlightCheck Professional. This is the easiest way t...
Building a Pro Street Softail Harley Custom Music Shinedown We built this pro-street custom softail for a former race car driver, so power and style were equally important to him. He was thrilled with the bike...




Search This Site:










control arch. questions.

searching for windows hosting reseller for chile

using a user control in a custom server control.

system.web.ui.design namespace not found by visual studio .net 2003

way to render a control in code-behind before the page is loaded?

calendar pop-up that selects multiple dates

create template with certain controls being the content.

redirect control source

free hosting(asp.net+sql 2005+bin file)

am i misunderstanding something?

discountasp.net

resolving design-time relative paths [also: getting paths from server control]

re-instantiate an inherited usercontrol in a repeater

preload event in controls

asp.net 2 - treenode inherit

create webmatrix toolbox component

tabbed control in asp.net

javascript and user control (ascx) help!

hosting bliss

can not resize the control at design time

extending repeater object

how to resize control in design time?

help files for controls

composite control design-time properties

property editor control?

windows product updates and technical training

cheap windows 2003 dedicated server ?

where to post developed controls?

custom control within a control control

datalist paging with search feature

  Privacy | Contact Us
All Times Are GMT