473,386 Members | 2,114 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,386 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 3253
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.