C
Chris
I have a question on whether or not this is good practice. I have a
fairly complex web user control (a datalist embedded in a datalist
with lots of controls) that I will call Usercontrol1 and a lot of code
in the codebehind of the user control for setting/getting properties
of the controls. What I would like to do is create a class like this:
public class MyClass
{
UserControl1 _userControl
public MyClass(UserControl1 userControl)
{
_userControl = userControl;
}
public void SetView()
{
_userControl.TextBox1.Text = "sometext";
Label labale1 =
(Label)_userControl.GetControl("controltofind");
etc., etc.
}
}
I want to instantiate MyClass in the UserControl1 codebehind using the
this keyword and use MyClass to set the values for my user control.
MyClass myClass = new MyClass(this);
Is this good practice and will this create any issues? I know in
theory it will work, because I have tested it (at least with one web
user, but not with multiple web users).
This would make the codebehind much more compact and readable.
fairly complex web user control (a datalist embedded in a datalist
with lots of controls) that I will call Usercontrol1 and a lot of code
in the codebehind of the user control for setting/getting properties
of the controls. What I would like to do is create a class like this:
public class MyClass
{
UserControl1 _userControl
public MyClass(UserControl1 userControl)
{
_userControl = userControl;
}
public void SetView()
{
_userControl.TextBox1.Text = "sometext";
Label labale1 =
(Label)_userControl.GetControl("controltofind");
etc., etc.
}
}
I want to instantiate MyClass in the UserControl1 codebehind using the
this keyword and use MyClass to set the values for my user control.
MyClass myClass = new MyClass(this);
Is this good practice and will this create any issues? I know in
theory it will work, because I have tested it (at least with one web
user, but not with multiple web users).
This would make the codebehind much more compact and readable.