0

I have a String variable that contains control type. Example: "Button", "TextBox" or "Label". I want to get PropertyInfo from this Variable. I have run this code but in first line return Null:

Type type = Type.GetType(ControlType);
PropertyInfo[] properties = type.GetProperties();

any idea?

0

1 Answer 1

1

Type.GetType() requires an assembly qualified name, and is case sensitive.

So for a windows forms app it would be in the format:

Type.GetType("System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"`

For webforms it would be the System.Web.UI.WebControls namespace, etc.

Sign up to request clarification or add additional context in comments.

4 Comments

what is type "formsAssembly" variable ?
@Mohadeseh_KH Assembly. But I've removed that bit anyway as LoadWithPartialName is marked as obselete..
Not sure what you mean by 'other systens'?
i mean that other version of Visual Studio..example lower or higher

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.