Saturday, March 31, 2012

string to object

Hi

How to convert string to object?

i.e.

string objname = "Control1"

then some how use (function or method)

objname.visible = false

Hi There,

asmgx:

How to convert string to object?

i.e.

string objname = "Control1"

then some how use (function or method)

objname.visible = false

You can assign string value to object

e.g

string value = "control1";

object obj = value;

But not using string value to identify as object.

However, you can use string value as id and find the control.

e.g

Say you wanted to get textbox with id myTextBox

TextBox txt = (TextBox)this.FindControl("myTextBox"); //


in c#

String obj ="Control1";

Object objCast = ((Object)obj);

in vb

Dim objAsString = "Control1"

Dim objCastAsObject = (CType(obj,Object))

asmgx:

then some how use (function or method)

objname.visible = false

what exact you want to do?

0 comments:

Post a Comment