easy question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have this easy piece of code:

public class Box1:System.web.ui.webcontrols.webcontrol
{
protected Button mybutton;
protected override void OnInit()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Controls.add(mybutton);
}
}
public class Gereral_Control:System.web.ui.webcontrols.webcontrol
{
protected Box1 mybox1=new Box1();
protected override void OnInit(EventArgs e)
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Controls.add(mybox1)
}
}

Take in count this piece of code, how could i make that: when i press the button (the button inside the webcontrol Box1) appears some textboxes and another button?(something like a form)

Thanks in advance.
Wong chian.
 
Hi,

I think it would be better to do that in client-side JavaScript code,
provided there are no browser limitations preventing you from using
JavaScript and DHTML. You should re-post your question in the
microsoft.public.dotnet.framework.aspnet newsgroup otherwise.

Briefly, you should expose an event from the Box1 control which is raised
when the button is pressed (you will most likely raise it from a
Button_Click handler). Then, the parent control handles the exposed event
upon postback and adds necessary controls to its Controls collection in the
event handler.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Wong chian said:
Hi,

I have this easy piece of code:

public class Box1:System.web.ui.webcontrols.webcontrol
{
protected Button mybutton;
protected override void OnInit()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Controls.add(mybutton);
}
}
public class Gereral_Control:System.web.ui.webcontrols.webcontrol
{
protected Box1 mybox1=new Box1();
protected override void OnInit(EventArgs e)
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Controls.add(mybox1)
}
}

Take in count this piece of code, how could i make that: when i press the
button (the button inside the webcontrol Box1) appears some textboxes and
another button?(something like a form)
 
Hi Dmitriy.
First of all, thanks for your answer...

I have some difficulties to make this in javascript, due that the form that i want to generate, is dinamic, exactly my problem its that when a user select a Initial Catalog in my application, there are a web custom control that shows the tables, and when the user select the table if after that click in a button (the text of the button is insert), the application generate the neccesary textboxes, to insert a new record in that initial catalog, and in that table chosen...

Could you give me an advice, sometimes for me its very difficult the comunication between the webcustom controls...
thanks
josema
 
What is your problem in communication between Web controls? In most cases,
events work just fine.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

josema said:
Hi Dmitriy.
First of all, thanks for your answer...

I have some difficulties to make this in javascript, due that the form
that i want to generate, is dinamic, exactly my problem its that when a user
select a Initial Catalog in my application, there are a web custom control
that shows the tables, and when the user select the table if after that
click in a button (the text of the button is insert), the application
generate the neccesary textboxes, to insert a new record in that initial
catalog, and in that table chosen...
Could you give me an advice, sometimes for me its very difficult the
comunication between the webcustom controls...
 
Webcontrol1
________________________
| |
|initialize component |
| button +=new event..... |
| controls.add(button) |
| |
|event onclick |
| -control.add(webcontrol2) |
----------------------------------

webcontrol2
_____________________________
| |
| InitializeComponent |
| button2 +=new EventHandler...|
| -controls.add(textbox) |
| -controls.add(button2) |
| Onlclick |
| Response.write("hello") |
 
Back
Top