473,386 Members | 1,832 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,386 software developers and data experts.

MVC and Wiring Up Events - An OOP Question

Though I'm new to C#, I've successfully built an MVC (Model-View-Controller)
Framework - with much thanks to the help of the great people on here!

Anyhow, my MVC Framework, which I call "ASM" for "Automated Synchronization
Mechanism" allows one to easily link:
- A data model with any hierarchical configuration
- A form (ie. view) with any combination of controls

Linking is established by simply entering the location of a given property
into the Tag of the form control it is associated with. So, for example, I
have a Boolean property called "CanPrint" that is located in a nested class
called "Privileges". Thus, into the Tag I enter:
"Property=Privileges.CanPrint" and then the ASM framework takes care
of the rest!

Coming from the VB6 world, I'm pretty amazed with what C# (and Reflection)
can do!

So that part is working perfectly! But what I have a question about is
wiring up Properties that exist within a Collection. I'm thinking of doing
something but am not sure if it violates proper OOP methodology.

In the Controller I plan to add a new Collection object this way:

_Question quest = new _Question(model.Questions);
quest.ModelEvent += new ASMEventHandler(PropertyEventHandler);
quest.ID = 1;
quest.Text = "Sample text for Question #1";
model.Questions.Add(quest);

where "_Question" is a nested class of the model. But do you see the 2nd
line, where I wire up the event? This seems rather clumsy to me have to add
it here. Not only do I have to add it in the Controller, but it has to be
added before I set the two properties.

The reason it has to be added here is because the data model is a child of
the Controller and has no idea about the existence of the Controller.

So (in much too long winded a way, I apologize!) in an MVC setup, is it
inappropriate to provide a reference to the Controller within the Model? For
if I did that then this kind of code could be put right into the model, which
would make it a lot cleaner, in my opinion. But I'm not sure if I'd be
stepping down a wrong path in doing so.

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
0 1244

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott M | last post by:
I'm building a smart client application based off of the example that is posted on windowsforms.com (and shown on the .NET show). A windows form calls a webservice that itterates through a...
0
by: Chris Fink | last post by:
I am writing a c# unattended windows application and I would like to write an event to handle any type of application error by gracefully degrading and writing a message to an error log. Errors...
3
by: Robert W. | last post by:
I have several instances where I wire up an event handler like this: // Instantiate object childClass parentObject = new childClass(); // Wire up event parentObject.SomeChildEvent += new...
2
by: Eldon Ferran de Pol | last post by:
I'm trying the dynamically wire up events for a load of LinkButtons contained within an <asp:Table>. For some reason if I try and do this outside the Page_Load event my events simply don't fire...
4
by: Jordan | last post by:
I need to dynamically add an ImageButton control to a user control and and do some server-side processing when the user clicks it. While I the ImageButton is added to the user control at runtime,...
4
by: Tomasz | last post by:
Hello Developers, Here is interesting problem I just came across: how do I wire a GridView control programmatically? Here is my sample code using Object Data Source: protected void...
5
by: Andrew Robinson | last post by:
I have a page that can load a number of different user controls. Each of these user controls inherits from a common base class and the controls are loaded based on application state, status, etc...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
1
by: spoonybard | last post by:
Hi Everyone, Recently, when I was trying to wire up an event for a GridView inside an AJAX Accordion, I was doing the wiring up in the code behind. The event never fired. When I moved that...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.