Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-09
2
Medium Priority
?
598 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

916 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