DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Dynamic Server Control event handling (http://www.daniweb.com/forums/thread159255.html)

vimalfor5 Nov 24th, 2008 12:10 pm
Dynamic Server Control event handling
 
Hi All,

Please help me to complete the following type of event handling in asp.net with C#

private TableCell CreateTextCell(string name,string id)
{
  TableCell cell = new TableCell();
  TextBox txt = new TextBox();
  txt.ID = id;
  txt.AutoPostBack = true;
  txt.Text = name;
  txt.TextChanged += new System.EventHandler(this.txt_Changed);
  cell.Controls.add(txt);
  return cell;
}

My Problem is the TextChanged event is not calling or it is not properly handling.. the autopostback is working fine.. but the event handler not..
and one thing I'm using .net 1.1 version in VS2003

Please give me a suggestion

Vimal

serkan sendur Nov 24th, 2008 3:17 pm
Re: Dynamic Server Control event handling
 
where is your txt_changed method? what is the problem?

vimalfor5 Nov 24th, 2008 5:30 pm
Re: Dynamic Server Control event handling
 
Hi Serkan,

The code structure is like
PageLoad -> above method ->

protected void Text_Changed(object sender,EventArgs e)
{
  TextBox t1 =null;
  t1 = (TextBox)sender;
......
......
}

dickersonka Nov 24th, 2008 6:02 pm
Re: Dynamic Server Control event handling
 
i believe when you are creating the controls dynamically like that, the control is not there that signaled the event

http://gregmckinley.com/cs/blog/arch.../09/29/27.aspx

serkan sendur Nov 25th, 2008 10:28 am
Re: Dynamic Server Control event handling
 
ok, there is one big difference between .net framework 1.1 and 2.0, in 1.1 you have to wire the events to the methods in the page init event handler. Tell me what exactly you want to do with these table cells. Watch the execution order of events during the page cycle. that is the most typical problem for such issues.

vimalfor5 Nov 25th, 2008 12:42 pm
Re: Dynamic Server Control event handling
 
Hi

Actually i want to update some other cells + Some calculations also there whenever the dynamically created text field changed, thats the main thing i want to do. Coz the each and every cell in that page is dynamically created. I Have tried alot to do that Event handling.
I dnt want to use Ajax features in this app.
i knows the limitations of 1.1 and to 2.0 ...
Now i', trying the same thing with the JavaScript..

serkan sendur Nov 25th, 2008 2:33 pm
Re: Dynamic Server Control event handling
 
yeah your best bet would be javascript.


All times are GMT -4. The time now is 11:45 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC