Find Control in .NET

It is a way of handling Nested control (NET controls on NET Container Controls) because these nested controls are never available in coding hence we need to find them before using them like normal controls.

Suppose you have a Asp.NET Linkbutton named “lnkSubCategory” and you have placed that in a repeater control named “rptCategories”. Now when you want to change the URL of that LinkButton or even want to change the text of that and you start writing name of that linkbutton in code behind file of that page but server will start displaying “lnkSubCategory is not declared” error.

You will have to ‘find that control’ first and you ned to find that linkbutton on some event of your repeater control. Suppose we have a method of Databinding of repeater so you can find your linkbuuton in that method. in our example we need to write line

 

Dim lnkSubCat as linkButton= Ctype(e.FindControl(“lnkSubCategory “), LinkButton)

 

Now you can user lnkSubCat and can use now as a normal LinkButton control.

 

Cheers and Happy Coding.

About Sallah Ud Din Sarwar

I am a multi skilled Software Engineer with over 14 year’s industry experience in designing and developing Object oriented solutions in Multi layered & N-Tired. I have substantial success to my credit. I have consistently handled complex problems to the satisfaction of my clients by working in stressful situations. I enjoy learning and applying new technologies in a dynamic and forward thinking professional environment.

Check Also

Unraveling Node.js – Essential Insights for Backend Development

Unraveling Node.js – Top 30 Interview Q&A Explained Introduction: Discover the essential concepts and interview …

Leave a Reply