Solved

ASP.Net/C# - FindControl with Guid always one control in placeholder?

Posted on 2010-09-09
2
582 Views
Last Modified: 2012-08-13
I am trying to figure out the simplest and cleanest way to handle this.  I have some code where I swap out the user control such as a textbox, dropdownlist etc.  I was naming the control the same ID name but that was causing errors.  I now have the same name and then appending a GUID to the end of it to make sure I stay unique on the control name.  How do I now do my findcontrol on it?  I was hoping I don't have to loop through all the controls or use Session but I may be heading down this road.  I don't want to use session at all for sure.  Is there a way to use FindControl and a partial string?  I know the start of it:

ID = "thenValue_" + guid,

Also I always only have 1 control in this placeholder at a time and if that can be used and checking to see if a control exists first that would also be perfect.

Thanks all
0
Comment
Question by:sbornstein2
2 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 33637677
not getting the exact problem you are facing...
If you have single control in a PlaceHolder then looping should be a big problem...since you have a single contol.
To check number of controls you can use PlaceHolder1.Controls.Count
0
 

Author Closing Comment

by:sbornstein2
ID: 33711094
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short film showing how OnPage and Connectwise integration works.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now