Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem using dynamically created textboxes

Reply
Thread Tools

Problem using dynamically created textboxes

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-17-2005
I am making a webform that allows the user to add another textbox by
clicking a button to allow them to enter however many names they need. The
procedure that does this uses information entered in the currently existing
textboxes. This works fine the first time they click the button, since the
first textbox is hardcoded. However, the second time they click the button I
recieve an error saying:

[NullReferenceException: Object reference not set to an instance of an
object.]
PAPresenters.register.btnAddName_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\PAPresenters\register.aspx.vb:1 28
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()

When I do a view source on the page, it gave the generated textboxes the ID
that I told it to. I think the problem has something to do with ASP.NET
forgetting the new controls when it looks for them the second time or
something. The line of code where I recieve the error is:

Line 126: 'Make sure there are no empty name fields
Line 127: For i As Integer = 0 To namecount
Line 128: If CType(FindControl("txtFName" & CStr(i)),
TextBox).Text = "" OrElse CType(FindControl("txtLName" & CStr(i)),
TextBox).Text = "" Then
Line 129: Exit Sub
Line 130: End If

Why is ASP.NET unable to find the dynamically created controls? Thanks.
--
Nathan Sokalski

http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
How do you query the values of textboxes dynamically created in a Panel container?? SD ASP .Net 3 06-23-2005 10:06 PM
Problem using dynamically created textboxes Nathan Sokalski ASP .Net 0 06-17-2005 06:46 AM
TextBoxes created dynamically : How to store data? Forconi Boris via .NET 247 ASP .Net 2 06-18-2004 09:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57