473,394 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

modify a constructor

Hi to all. I have the small class below. and a webform
empty to test this class...

If i call to the method generate fields the application
show me the fields, if i click the button the controls
dissapear. But if in the constructor of the class below i
add the controls, this controls dont dissapear if i click
the button in the webform...

Why?

public class
mywebcontrol:System.Web.UI.WebControls.WebControl
{

public TextBox MyTextBox
{
get{return mytextbox;}
set{mytextbox=value;}
}
public Button MyButton
{
get{return mybutton;}
set{mybutton=value;}
}
public mywebcontrol()
{this.MyButton.Click+=new EventHandler
(MyButton_Click);
}
public void MyButton_Click(object sender, EventArgs
e) {
HttpContext.Current.Response.Write (this.MyTextBox.Text);
}
public void Generate_Fields()
{ TextBox new_textbox=new TextBox();
this.MyTextBox[i]=new_textbox;
this.Controls.Add(this.MyTextBox[i]);
this.Controls.Add(this.MyButton);
}
}
}

Thanks In advanced
The main program...
Nov 15 '05 #1
0 1047

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jun | last post by:
I have following script <script> var Animal = function(name){ this.name = name; } Animal.prototype.eat = function (food) {
15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
0
by: livinginmatrix | last post by:
Hi to all. I have the small class below. and a webform empty to test this class... If i call to the method generate fields the application show me the fields, if i click the button the controls...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
6
by: TZ | last post by:
I have two classes, UIHousehold and WIZEditHousehold (both are winforms). UIHousehold creates and shows the WIZEditHousehold (WIZEditHousehold can't be modal, so UIHousehold doesn't know when...
2
by: Vols | last post by:
I have a class that many libraries depend on. If I modify the class with 'adding an argument with default value to an existing member function', is it necessary to recompile all library? How about...
8
by: Jose Cintron | last post by:
Hello all. Newbie question here... I have a program that needs to do 1 of 2 things 1. declare a global System::String (which I think can't be done, because VS 2005 complains) 2. modify the...
3
by: Huayang Xia | last post by:
I get a python object by running a class' constructor. Then I need to modify the instance's attribute just like obj.attr1.attr2 = 'a' if in python's term. PyObject* py_obj_attr1 =...
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
7
by: Boki | last post by:
Hi All, I want to change WindowState of form1 from form2. I tried these two methods, but no luck on both. (1) Declare a public method: /* function of form1 */ public void...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.