943,708 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 4106
  • ASP.NET RSS
Nov 24th, 2008
0

Dynamic Server Control event handling

Expand Post »
Hi All,

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

C# Syntax (Toggle Plain Text)
  1. private TableCell CreateTextCell(string name,string id)
  2. {
  3. TableCell cell = new TableCell();
  4. TextBox txt = new TextBox();
  5. txt.ID = id;
  6. txt.AutoPostBack = true;
  7. txt.Text = name;
  8. txt.TextChanged += new System.EventHandler(this.txt_Changed);
  9. cell.Controls.add(txt);
  10. return cell;
  11. }

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
Last edited by vimalfor5; Nov 24th, 2008 at 12:11 pm. Reason: mistake correction
Reputation Points: 10
Solved Threads: 1
Newbie Poster
vimalfor5 is offline Offline
10 posts
since Sep 2007
Nov 24th, 2008
0

Re: Dynamic Server Control event handling

where is your txt_changed method? what is the problem?
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Nov 24th, 2008
0

Re: Dynamic Server Control event handling

Hi Serkan,

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

c# Syntax (Toggle Plain Text)
  1. protected void Text_Changed(object sender,EventArgs e)
  2. {
  3. TextBox t1 =null;
  4. t1 = (TextBox)sender;
  5. ......
  6. ......
  7. }
Last edited by vimalfor5; Nov 24th, 2008 at 5:32 pm.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
vimalfor5 is offline Offline
10 posts
since Sep 2007
Nov 24th, 2008
0

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
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 25th, 2008
0

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.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Nov 25th, 2008
0

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..
Reputation Points: 10
Solved Threads: 1
Newbie Poster
vimalfor5 is offline Offline
10 posts
since Sep 2007
Nov 25th, 2008
0

Re: Dynamic Server Control event handling

yeah your best bet would be javascript.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: IE7/saving pages problem
Next Thread in ASP.NET Forum Timeline: application extension problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC