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 2nd, 2003, 07:52 AM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET Server Controls

Hi,

I'm trying to create a very simple ASP.NET server component without compiling. I'm basing my test control off of an example in Wrox's "ASP.NET Server Controls (Building Custom Controls with C#)".

Here is what I have

File = test.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Steve
{
    public class Test : Page
    {
      private Button b = new Button();

      protected override void CreateChildControls()
      {
        b.Text = "Before Click";
        Controls.Add(b);
        b.Click += new EventHandler(this.Clicked);
      }

      private void Clicked(Object sender, EventArgs e)
      {
        b.Text = "After Click";
      }
    }
}


File - test.aspx

<%@ Page Language = "C#" Inherits = "Steve.Test" Src = "test.cs" runat = "server" %>

<html>
  <body>
    Will my button work? <br>
  </body>
</html>

When I run this page, the button display, but I can't get the "Clicked" event to fire. Nothing happens when I click on the button. Any ideas why?

Thanks
-Steve






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic generation of asp.net server controls shashi1312 Classic ASP XML 1 August 2nd, 2005 04:52 AM
Asp.Net Server Controls Overlapping Problem vinod_pawar1 General .NET 1 August 15th, 2004 06:20 PM
Asp.Net Server Controls Book missing vkarlo Wrox Book Feedback 2 August 15th, 2003 10:36 AM
ASP.NET server side controls me_shriram VS.NET 2002/2003 3 August 11th, 2003 03:55 AM





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