473,322 Members | 1,287 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,322 software developers and data experts.

User Controls

Thank you for any help you can provide.

This is what I have:
index.aspx - contains nothing but a form with runat = server
header.ascx - contains asp image box
welcome.ascx - contains text
footer.ascx - contains text
login.ascx - contains asp/web labels and text boxes.

The index page is simply a container for all the user controls. The
header, footer, and welcome controls are always included. The login
control should only be included if the user has not logged in.

Everything runs perfectly if the login control in not included. When
the login control is included I get an error saying that the control
_ctl1_txtUser must reside between the form tags with runat set to
server. The actual control name is txtUser. I understand why the
name changes. What I don't understand is why it has to be in the form
tag. While investigating, I have read in other threads that controls
on user controls are rendered between the form tags of the parent
object. Can anyone offer any suggestions?
Nov 17 '05 #1
4 3241
Jos
Michael wrote:
Thank you for any help you can provide.

This is what I have:
index.aspx - contains nothing but a form with runat = server
header.ascx - contains asp image box
welcome.ascx - contains text
footer.ascx - contains text
login.ascx - contains asp/web labels and text boxes.

The index page is simply a container for all the user controls. The
header, footer, and welcome controls are always included. The login
control should only be included if the user has not logged in.

Everything runs perfectly if the login control in not included. When
the login control is included I get an error saying that the control
_ctl1_txtUser must reside between the form tags with runat set to
server. The actual control name is txtUser. I understand why the
name changes. What I don't understand is why it has to be in the form
tag. While investigating, I have read in other threads that controls
on user controls are rendered between the form tags of the parent
object. Can anyone offer any suggestions?


Just move the <form runat="server"> and </form> tags in the body
of your index.aspx file, in such a way that the login user control
is included.

--

Jos
Nov 17 '05 #2
Michael,

I am assuming you are using the dynamic loading of the
form. This is where you add controls from the code. If
not completely ignore this post because it will confuse
you and go with the suggestion of Jos.

You should put a panel inside the <form></form> and add
all of your components to it. That way you can assure
that your components are added in the correct location.

Another suggestion (not sure if this one will work, but I
am assuming it will) would be to name your form tag and
add your items to the form tag. This again will assure
that you have you items added inside your form tags.

Something else to consider, You don't have to load these
controls dynamically. You can actually set their
visibility to true or false depending on if you would
like to display them.

I have no proof of this, but I think the dynamic loading
will be quicker because you are not loading all of the
objects every time you load the page. You are only
loading those that you specify based on if the user is
logged in or not.

There is a great example of this in the IBuySpy portal at
http://www.asp.net/Default.aspx?tabindex=5&tabid=42.
This has also evolved into http://dotnetnuke.com

Keith
-----Original Message-----
Thank you for any help you can provide.

This is what I have:
index.aspx - contains nothing but a form with runat = serverheader.ascx - contains asp image box
welcome.ascx - contains text
footer.ascx - contains text
login.ascx - contains asp/web labels and text boxes.

The index page is simply a container for all the user controls. Theheader, footer, and welcome controls are always included. The logincontrol should only be included if the user has not logged in.
Everything runs perfectly if the login control in not included. Whenthe login control is included I get an error saying that the control_ctl1_txtUser must reside between the form tags with runat set toserver. The actual control name is txtUser. I understand why thename changes. What I don't understand is why it has to be in the formtag. While investigating, I have read in other threads that controlson user controls are rendered between the form tags of the parentobject. Can anyone offer any suggestions?
.

Nov 17 '05 #3
Michael,

If you want to dynamically load the control to the page use a placeholder
control. The placeholder control simply shows where a dynamically loaded
control will appear on the page.

My website, www.aboutfortunate.com, uses a single page for the entire site
and switches it's content by dynamically loading various user controls into
a single placeholder.

If you'd like example code for doing so it's located in the site's code
library. Just click on the code library and then use the search box there to
search for: "dynamically load user control" or something similar and you'll
find the example.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michael" <mi******@acer-access.com> wrote in message
news:fa**************************@posting.google.c om...
Thank you for any help you can provide.

This is what I have:
index.aspx - contains nothing but a form with runat = server
header.ascx - contains asp image box
welcome.ascx - contains text
footer.ascx - contains text
login.ascx - contains asp/web labels and text boxes.

The index page is simply a container for all the user controls. The
header, footer, and welcome controls are always included. The login
control should only be included if the user has not logged in.

Everything runs perfectly if the login control in not included. When
the login control is included I get an error saying that the control
_ctl1_txtUser must reside between the form tags with runat set to
server. The actual control name is txtUser. I understand why the
name changes. What I don't understand is why it has to be in the form
tag. While investigating, I have read in other threads that controls
on user controls are rendered between the form tags of the parent
object. Can anyone offer any suggestions?

Nov 17 '05 #4
Thank you everyone for your suggestions.

Justin,

This is exactly what I was looking for. I have and index page and the
content (user control) will change with the users selections.

Thank you,
Michael
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message news:<#j**************@tk2msftngp13.phx.gbl>...
Michael,

If you want to dynamically load the control to the page use a placeholder
control. The placeholder control simply shows where a dynamically loaded
control will appear on the page.

My website, www.aboutfortunate.com, uses a single page for the entire site
and switches it's content by dynamically loading various user controls into
a single placeholder.

If you'd like example code for doing so it's located in the site's code
library. Just click on the code library and then use the search box there to
search for: "dynamically load user control" or something similar and you'll
find the example.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michael" <mi******@acer-access.com> wrote in message
news:fa**************************@posting.google.c om...
Thank you for any help you can provide.

This is what I have:
index.aspx - contains nothing but a form with runat = server
header.ascx - contains asp image box
welcome.ascx - contains text
footer.ascx - contains text
login.ascx - contains asp/web labels and text boxes.

The index page is simply a container for all the user controls. The
header, footer, and welcome controls are always included. The login
control should only be included if the user has not logged in.

Everything runs perfectly if the login control in not included. When
the login control is included I get an error saying that the control
_ctl1_txtUser must reside between the form tags with runat set to
server. The actual control name is txtUser. I understand why the
name changes. What I don't understand is why it has to be in the form
tag. While investigating, I have read in other threads that controls
on user controls are rendered between the form tags of the parent
object. Can anyone offer any suggestions?

Nov 17 '05 #5

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

Similar topics

1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
2
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
0
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
1
by: Demetri | last post by:
I'm trying to determine if we want to use panels or user controls for our pages. Our primary concern is performance, page loading and posting speed. To illustrate my question, lets use the...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
3
by: Terry Olsen | last post by:
I'm trying to add a domain user to a local group using the code below: Dim LCL As New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer") Dim DOM As New...
1
by: zeya_bakhtyar | last post by:
Here is the page architecture: Page loads multiple user controls (including nested user controls) dynamically based on parameters provided into place holders. Note: The page only has the logic to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.