473,666 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 2912
fastestindian
74 New Member
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
2368
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 http://www.tonymarston.co.uk/php-mysql/model-view-controller.html and tell me why my implementation of the MVC design pattern is totally wrong. Go on, I dare you. Make my day. -- Tony (a legend in his own lunchtime) Marston
7
2522
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 application into Model, View and Controller parts? For example: I have some classes: class FlatWorld;
1
2190
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: (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpFrontControllerInASP.asp) The irony of microsoft asp.net sample is it does not work...and the WORKAROUND as they say it is provide in article...
37
5949
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 in a separate file from the HTML. Apart from the obvious advantage if you have a separate designer and programmer, are there any other advantages to code behind? Most of the stuff I've seen so far uses code inside, but that's probably
19
2883
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 layer, and the business layer is coupled to the data layer. So far so good. Suppose the data layer raises an event, and it passes Me (the sender) as an object, and e (MyEventArgs, a descendent of EventArgs) to the layer above (the business...
4
1586
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
1090
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: http://www.ingeniousapps.com/Products/IngeniousMvc/Introduction.aspx#ID0EQF Is MS doing something ? Is ASP.NET 2.0 sufficient? Thanks,
1
1267
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 words, what could allow for "master/parent" functions without having to duplicate them to every single form? I've used user controls (instead of forms) for various "modules" and insert them onto a master form, but is this my only other...
11
3284
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 applications, fully working web-sites for paying costumers. I have 2 options for doing this: writing everything with plain PHP, or using some PHP framework. I don't want to choose something and the realize that the other is batter. I want to get used for...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.