C# ASP.NET GetType() with WebUserControl issue -


in project have custom webusercontrols form elements (they encapsulate standard validators , other system specific functions). user controls "dropdownlistfield" , "textboxfield". in code behind of page have code:

string parametervalue = null; foreach (object control in mymultiview.views[mymultiview.activeviewindex].controls) {     if (control.gettype() == typeof(dropdownlistfield))         parametervalue = ((dropdownlistfield)control).value;     if (control.gettype() == typeof(textboxfield))         parametervalue = ((textboxfield)control).value; } 

for reason "if" statements return false when step through code , see "control" getting assigned web user control. code in place in project same except in other location standard .net controls "textbox" , "dropdownlist" used , in other location code works.

does know why wouldn't work web user controls?

update: hmm in debugging found this:

?control.gettype(); basetype: {name = "dropdownlistfield" fullname = "webui.usercontrols.fields.dropdownlistfield"} ?typeof(dropdownlistfield); basetype: {name = "usercontrol" fullname = "system.web.ui.usercontrol"} 

so typeof recognizing user controls not full type seems.

does know how check specific user control type?

i'm guessing aren't same type, use debugging find out actual type.

also, try using 'is' keyword instead.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -