.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 29th, 2005, 06:28 AM
jul jul is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 14 jul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 46 m 45 sec
Reputation Power: 0
Question C# and ASP.NET create a new Button Class

The problem is as follows:

I need to create a number of buttons, which is not known in advanced and will depend on the number of rows in the table. Further on, each button should have a function, which takes the information from that row, where the button is and do something to it.

At the moment I am just trying to make a button that will change the text of the label, just to see if it works.

The way I am doing it is- I am creating a new Button class extending WebControls.Button and overriding onClick( e)method. When I test it, I can see that the button is created exactly the way I wanted it to be, but when I click the method is not executed, the program never goes into it(I set the brake points to check it). It is obvious that the default method is executed instead, but why? Should I do anything with delegates instead?
This is the code example:

//aspx.cs file
//the button is created automaticaly, as many times as needed

protected System.Web.UI.WebControls.Label lab;

if(j==3)
{
Buttonnn btn=new Buttonnn(lab);
btn.Text="Edit_"+name;
c.Controls.Add(btn);
}

//Buttonnn class

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


namespace WebSolve
{

public class Buttonnn:System.Web.UI.WebControls.Button
{
protected System.Web.UI.WebControls.Label lab;


public Buttonnn(System.Web.UI.WebControls.Label lab)
{
this.lab=lab;
base.BorderWidth=6;

}
protected override void OnClick(EventArgs e)
{

lab.Text+="Clicked";
base.OnClick(e);
}
}
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > C# and ASP.NET create a new Button Class


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap