.NETGURU
Multiple User Controls on one Page
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.


MJK
Hi,

I have an ASP.NET page which has 2 instances of a user control which I've
created.

The control is a table with several text boxes which are populated with text
at the time of loading.

If I have only one control on the page, everything works as it should BUT
when there are two, the boxes are only populated in the second control!

I've been struggling with this for ages, can anyone shed any light on the
problem?

Thanks,
Dot Net Guru

Reply to this message...
 
    
DavidW
Basically, each one should have its own ID....then, you load each of them
separately, based on the ID...it's hard to tell what's wrong in your
situation without actually seeing your population code.

--
David Wier
http://aspexpress.com
Home of ASP Express - the best ASP text editor in the Galaxy
First editor with ASP.Net features
"MJK" <Click here to reveal e-mail address> wrote in message news:695840@aspngreuse...
[Original message clipped]

Reply to this message...
 
    
MJK
Each control does have it's own id. Hopefully these code extracts will help:

concert.aspx:

At the top:

<%@ Register tagprefix="BoxOffice1" tagname="Box1" src="boxoffice.ascx"%>

Then in the code:

<boxoffice1:box1 id="AddBox1" runat="server"></boxoffice1:box1>

and

<boxoffice1:box1 id="AddBox2" runat="server"></boxoffice1:box1>

concert.aspx.vb:

At the top I have:

Public Class _concert
Inherits System.Web.UI.Page
Public addbox1 As boxoffice
Public addbox2 As boxoffice

Then, the edit function in the user control is called like this:

addbox1.edit(CInt(cmbBox1List.SelectedItem.Value))

(addbox2.edit for the second one)

boxoffice.ascx.vb:

The function is:
Public Sub edit(ByVal intID As Integer)
Label2.Text = "Here"
'loads more code here
end sub

Regards,
Dot Net Guruhew

"DavidW" <Click here to reveal e-mail address> wrote in message news:696187@aspngreuse...
[Original message clipped]

Reply to this message...
 
    
MJK
Have found the cause of the problem.

I was declaring the server controls within the user control as Public Shared
Withevents. I don't know why but changing this to Protected Withevents
solved the problem.

"MJK" <Click here to reveal e-mail address> wrote in message news:696470@aspngreuse...
[Original message clipped]

Reply to this message...
 
 
System.Web.UI.Page




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification