Finding control type in ASP .NET if you only know the control name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can you find a control's type in ASP .NET (using C#, in Page_Load
function) if you only know the control's name?
 
Hey Joachim

If I understand you correctly you want to know the type of a control given
its name.

Given the contril is called Button2, You could try this:

string typeName = Page.FindControl("Button2").GetType().Name;

This will return "Button"

Hope that helps
 
Perfect! Thanks!

Rad said:
Hey Joachim

If I understand you correctly you want to know the type of a control given
its name.

Given the contril is called Button2, You could try this:

string typeName = Page.FindControl("Button2").GetType().Name;

This will return "Button"

Hope that helps
--


Bits. Bytes.
http://bytes.thinkersroom.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top