473,395 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

What normally goes inside an interface for controller? (mvc)

In mvc you separate view from controller. How do you do that in C#?

Many people define an interface for a controller but isn't controller is specific to a form(gui) which all controller contains is handle events from gui controls(button, treeviews, textboxes etc..) which you don't know until you code the form.

So is there a point in having an interface for a controller where that controller is tightly tied to a specific form.

Having said that, many people say that controller can be used with many forms - how? as i'm aware of is controller tied to specific gui controls (like is said above).

Basically what i think a controller is for handling gui events and that is depending on gui controls. am i correct?

If not, what is the correct way to do it? what goes inside interface for controller?

thanks in advance
Aug 19 '09 #1
1 2903
Hi Robert,

Windows application.
Expand|Select|Wrap|Line Numbers
  1. public partial class Form1 : Form, IUserView
  2.     {
  3.         UserViewPresenter _presenter;
  4.  
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.             _presenter = new UserViewPresenter(this);
  9.             _presenter.SetCustomerData();
  10.         }
  11.  
  12.         private void Form1_Load(object sender, EventArgs e)
  13.         {
  14.         }
  15.  
  16.         #region IUserView Members
  17.  
  18.         public string FirstName
  19.         {
  20.             set { firstname.Text=value; }
  21.         }
  22.  
  23.         public string LastName
  24.         {
  25.             set { lastName.Text = value; }
  26.         }
  27.  
  28.         public string Address
  29.         {
  30.             set { address.Text = value; }
  31.         }
  32.  
  33.         public string City
  34.         {
  35.             set { city.Text = value; }
  36.         }
  37.  
  38.  
  39.         public string ErrorMessage
  40.         {
  41.             set
  42.             {
  43.                 errorLabelMessage.Text = value;
  44.                 errorLabelMessage.Visible = value != "";
  45.             }
  46.         }
  47.  
  48.         public string SearchCriteria
  49.         {
  50.             get { return searchCriteria.Text; }
  51.         }
  52.  
  53.         #endregion
  54.  
  55.         private void searchButton_Click(object sender, EventArgs e)
  56.         {
  57.             _presenter.SetCustomerData();
  58.         }
  59.  
  60.     }
  61.  
Asp.net Application
Expand|Select|Wrap|Line Numbers
  1. public partial class _UserView : Page, IUserView
  2. {
  3.     private UserViewPresenter _presenter;
  4.  
  5.     protected void Page_Load(object sender, EventArgs e)
  6.     {
  7.         _presenter = new UserViewPresenter(this);
  8.         _presenter.SetCustomerData();
  9.     }
  10.  
  11.     protected void searchButton_Click(object sender, EventArgs e)
  12.     {
  13.         _presenter.SetCustomerData();
  14.     }
  15.  
  16.     #region IUserView Members
  17.  
  18.     public string FirstName
  19.     {
  20.         set { firstName.Text = value; }
  21.     }
  22.  
  23.     public string LastName
  24.     {
  25.         set { lastName.Text = value; }
  26.     }
  27.  
  28.     public string Address
  29.     {
  30.         set { address.Text = value; }
  31.     }
  32.  
  33.     public string City
  34.     {
  35.         set { city.Text = value; }
  36.     }
  37.  
  38.     public string ErrorMessage
  39.     {
  40.         set
  41.         {
  42.             errorMessageLabel.Text = value;
  43.             errorMessageLabel.Visible = value != "";
  44.         }
  45.     }
  46.  
  47.     public string SearchCriteria
  48.     {
  49.         get { return searchCriteria.Text; }
  50.     }
  51.  
  52.     #endregion
  53. }
  54.  
From above code we learn that we seperate out User Interface from Data.
so that same middle layer i.e. business logic need not to be change.
Aug 24 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tony Marston | last post by:
For those who you thought my method of implementing OO principles in PHP was totally wrong - see http://www.tonymarston.co.uk/php-mysql/good-bad-oop.html for details, you can now read...
7
by: hugo.elias | last post by:
Hi all, I hope nobody minds me posting this question to this group, but I couldn't find any group closer to the Subject. Can anyone clear up where you draw the lines when dividing up an...
1
by: NGM | last post by:
Hello All When implementing FrontController sample MSDN I am facing a lot of problems try implementing the front controller patterm sample provided by microsoft:...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
19
by: Charles Law | last post by:
Take a solution with a project hierarchy along the lines of an n-tier system, so that we have a data layer, business layer and presentation layer. The presentation layer is coupled to the business...
4
by: Kunle Odutola | last post by:
WebForms used to be a Page controller architecture (in .NET 1.x) which severely limited (prevented?) true MVC designs with WebForms. Any ideas? -- Don't talk unless you can improve the silence.
1
by: Lorenzo Jimenez | last post by:
It seems that there is a big problem in the web controller arena in MS because none can be found for ASP.NET 2.0. Maybe is because UIPAB (v 1 and 2) had flaws according to this article: ...
1
by: Ronald S. Cook | last post by:
I want to design/develop a Win app with an Outlook-like feel. That is, lots of different modules. If I don't go with Composite UI Application Block (CAB) design, how else could I do it? In other...
11
by: Michael | last post by:
I'm new to PHP, I already learned the basics of the language and built some little app's for practice. I have a critical dilemma, soon enough, I probably start to develop real-world...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.