Best way to find a control on a page?

Posted by Community Admin on 04-Aug-2018 15:52

Best way to find a control on a page?

All Replies

Posted by Community Admin on 01-Feb-2012 00:00

We have a control that contains an updatepanel. When updating this panel and doing a partial page update we also need to update a separate control that is in the page template. What's the best of finding this control?

(in this example we are talking about a custom product detail page, and updating a mini-basket  (also a custom control) on the template when someone clicks adds to basket (also a custom control)).

Posted by Community Admin on 02-Feb-2012 00:00

Hello Nick,

Could you please give us more details about your question - do you want to find the control from client-side code or server-side code? For server-side code you could assign a code-behind class to your page and use Page.FindControl or simply reference the control in the page. For client-size if you know the ID of your control you could use either some jQuery selector or the Microsoft AJAX $find() or $get() functions.

All the best,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-Feb-2012 00:00

It would be server side. I was going to go with the recursive lookup approach using .FindControl, but just wondered if Sitefinity had it's own internal mechanism for maintaining a list of controls. In previous applications we've built we've had our own custom base page class which we've used to maintain a reference to a specific control - the control registers itself with the page base class during init, so that other controls can then reference it from the base class without the recursive overhead of using FindControl each and every time. I'm not sure if this is doable in SF? Is it possible to use a custom page base class? Or I guess we could do it on the master page if not.

Posted by Community Admin on 06-Feb-2012 00:00

Hello Nick,

Please check the following blog post -

http://www.sitefinity.com/blogs/petermarinov/posts/11-12-27/sitefinity_and_the_asp_net_code-behind_model.aspx 

It outlines how to implement a custom code-behind class for your page where you can use the FindControl method to retrieve a reference to a page control.

Kind regards,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Feb-2012 00:00

Thanks, that looks to be exactly what I was after.

This thread is closed