Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:59:18+00:00 2026-06-15T15:59:18+00:00

Working on ASP.NET app, my project need to find control from page ,use bellow

  • 0

Working on ASP.NET app, my project need to find control from page ,use bellow syntax to find control from a page:

public static Control FindControlRecursive(Control Root, string Id)
{
    Control FoundCtl = new Control();
    if (Root.ID == Id)
        return Root;

    foreach (Control Ctl in Root.Controls)
    {
        if (FoundCtl != null && FoundCtl.ID == Id)
        {
            
            Type ty = FoundCtl.GetType();
            var r = FoundCtl as ty; 
            
            //var r = FoundCtl as  Telerik.Web.UI.RadComboBox;   
        }

        FoundCtl = FindControlRecursive(Ctl, Id);

        //if (FoundCtl != null)
        //    return FoundCtl;
    }

    return FoundCtl;
}

For retrieve control value from the control need to cast.
For cast use bellow syntax

FoundCtl as TextBox;
                

Is it possible to cast find control as bellow

Type ty = FoundCtl.GetType();
var r = FoundCtl as ty;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:59:19+00:00Added an answer on June 15, 2026 at 3:59 pm

    You cannot do this in such way. All cast operators is not work with variable of type System.Type . Moreover, if you want to work with this control in runtime with reflection, you can use reflection methods to work with it (such as PropertyInfo.SetValue etc).
    But usually you exatly know what type is of concrete control. Why do you want to cast in runtime?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The ASP.NET web app project I'm currently working on is getting slower over time
I'm working on an ASP.NET/C# app. I have 2 text boxes and I need
I’m working on trying to port an ASP.NET app from Server 2003 (and IIS6)
I'm working on an ASP.NET project where I need to split our current application
im working on a asp.net 3.5 app. i am trying to reference a public
I am working on a ASP.Net project creating a Outlook like calendar scheduler app.
I'm working on an ASP.NET web app in VS2010,C#. I've created a table for
I'm working on a asp.net mvc2 app. I have been using jquery to do
I am working on a asp.net web app in visual studio team system 2008
I'm working in Asp.net and IntelliSense isn't finding the methods in app code. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.