473,327 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Question about loading usercontrols

(I've been away from web app programming for a while. Most of my experience
has been in 1.1. Now I'm using vb/Dot Net 2.0)

Please explain a couple of things.

First, I have a simple-minded usercontrol defined. No real code so far.
Just a bunch of text boxes on a panel. I want to dynamically load one or
more instances of the usercontrol onto the screen.

Why is it that the command 'Me.Form.Controls.Add' will work with stock
controls (like a textbox) but apparently not with usercontrols? (After a
little bit of trial and error I found I could create usercontrols with the
'LoadControl' command. I think this is the first time I've heard of
'LoadControl'.)

2nd, in a basic web page, a control can be dynamically added with a call to
the default 'form1.controls.add'. My current test page has a master page and
I've found that 'form1' is not available. However 'Me.Form.Controls.Add()'
seems to work the same. Are there any 'gotchas' here that I should be aware
of?
Jul 24 '08 #1
1 1161

"B. Chernick" <BC*******@discussions.microsoft.comwrote in message
news:BE**********************************@microsof t.com...
(I've been away from web app programming for a while. Most of my
experience
has been in 1.1. Now I'm using vb/Dot Net 2.0)

Please explain a couple of things.

First, I have a simple-minded usercontrol defined. No real code so far.
Just a bunch of text boxes on a panel. I want to dynamically load one or
more instances of the usercontrol onto the screen.

Why is it that the command 'Me.Form.Controls.Add' will work with stock
controls (like a textbox) but apparently not with usercontrols? (After a
little bit of trial and error I found I could create usercontrols with the
'LoadControl' command. I think this is the first time I've heard of
'LoadControl'.)
A textbox is fully compiled, so it does not require UI helpers to render the
tagged portion of the page. A user control is a mixture of code and tags. It
would not make sense spinning cycles on a compiled control to check for
tags, so you have different methods.
2nd, in a basic web page, a control can be dynamically added with a call
to
the default 'form1.controls.add'. My current test page has a master page
and
I've found that 'form1' is not available. However
'Me.Form.Controls.Add()'
seems to work the same. Are there any 'gotchas' here that I should be
aware
of?
It is the same. I have never experienced the problem you talk about, but I
am not sure I have ever coded it that way, so that is a moot point. I am not
sure why you are not seeing the form name, but Me.Form points to the same
location.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************

Jul 24 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
Hi all, I'm having a little problem understanding the concepts of dynamically loading/unloading user conrols: 1. If I have a couple of usercontrols embedded within a few tables cells on my...
1
by: Sundaresan | last post by:
I've a form where I load two user controls dynamically. User Control-1 has a no.of dropdowns and based on the selection I typically populate a datagrid in the user control-2, Also the I could...
1
by: kanones | last post by:
Hi - I am seeing some performance degradation when I am loading a control dynamically onto a page with multiple other dynamical controls using Page.LoadControl versus dragging and dropping it...
0
by: Phl | last post by:
Hi, I am trying to create an webform which loads usercontrols dyanamically. I know exactly what to load for some of these controls but for some, I dont want to load it until the user has press a...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
6
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
0
by: Johnny Emde Jensen | last post by:
Hello Why this. I have a form (frmWorkspace), with some splitter controls. on each splitter panel i place my own usercontrols. One of the usercontrols (ctlWorkbook) have a dynamic...
5
by: marfi95 | last post by:
I have a form that has a left and right panel. In the left panel is a treeview. The right panel I want to change dynamically based on the type of node selected. What I'm doing is loading the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.