Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

Reply
Thread Tools

Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

 
 
Denny Smolinski via .NET 247
Guest
Posts: n/a
 
      05-04-2004
I have been searching forever. Here is my problem.

I have form of 3 panels of information for car insuranceinformation.

1st panel is general information but I need to retrieve theNUMBER OF FAMILY members to see how many names I need for mynext panel that is dynamically generated based upon my drop downlist selection. I can generate panel 2 with the number of namesI need but the problem is then posting the data from thetextboxes to the next page.

ERROR: Object reference not set to an instance of an object.

I try to retrieve from a dynamic box txt1, txt2, etc. I havetried creating the boxes on the fly and even in the page_initsection and just set visible = false. Please if anyone couldhelp. Thank you

--------------------------------
From: Denny Smolinski

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>GcCBM0LoGUWK0X3cuePCRA==</Id>
 
Reply With Quote
 
 
 
 
Eidolon
Guest
Posts: n/a
 
      05-04-2004
One mistake that drove me batty at first with dynamic controls and
apparently is a very common mistake from what i saw online is this...

In order to get anything out of your previous control, you MUST add it back
into the control heirarchy at EXACTLY the same place (this is where the
placeholders come in handy) as it was before, otherwise the framework will
not be able to repopulate it all. Here is the way i do this. This has worked
flawlessly and beautifully for me.
In my page i put the following:

I add a Literal control named "ltlLastControl", and set the Text property to
the path for my first/default ascx file.
I add a PlaceHolder control named "bucket".

In my Page_Load I add the following code as the first line:
<code>
If Me.LastControl <> "" Then SwapControl(Me.LastControl)
</code>

Then i also add the following code to my page:
<code>
Protected ReadOnly Property LastControl() As String
Get
Return ltlLastControl.Text
End Get
End Property

'// NewControl receives the ASCX path to load
Protected Sub SwapControl(ByVal NewControl As String)
Dim ctl As Web.UI.Control = LoadControl(NewControl)

bucket.Controls.Clear()
bucket.Controls.Add(ctl)

ltlLastControl.Text = NewControl
End Sub
</code>


 
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
Dynamic Controls created by Dynamic Controls Ronald ASP .Net 2 01-17-2006 12:44 AM
Web Project - Unable to retrieve folder information from the server Grant Merwitz ASP .Net 0 06-21-2005 04:46 PM
Retrieve posted information Dan Avni ASP .Net 3 06-22-2004 09:21 AM
retrieve all information from domain vaidas gudas ASP .Net 3 06-18-2004 09:47 AM
How to Retrieve user information using Active Directory Federica ASP .Net 0 04-18-2004 12:59 PM



Advertisments