473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=Privi leges.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.ModelEven t += new ASMEventHandler (PropertyEventH andler);
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 1254

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

Similar topics

1
2294
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 directory, pulling meta data from all the assemblies located in that directory. Then returns that information for the form to consume and to be able to...
0
1412
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 should never be visible or pause program execution, in case of an error program should just exit and write error to logfile. I would like to...
3
4093
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 EventHandler(ParentEventHandler);
2
1365
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 despite the correct postback code being added on the client and the postback taking place. Can anyone help please? Eldon
4
3008
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, as needed, I'm having trouble wiring up its click event procedure. The problem is that when I go to subscribe the ImageButton to the delegate, the...
4
12539
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 Page_Load(object sender, EventArgs e) { ObjectDataSource ods = new ObjectDataSource("MyTestTableAdapter",
5
3067
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 and the specific type of control frequently changes. I have a common event in the base class that each child user control inherits from and that the...
12
13414
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 file was built by draging tables from the Data Sources pane. Auto-generated code created the files associated wtih the XSD file (xss,
1
1549
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 declaration into the HTML markup, the event fired and worked properly. Just today I experienced the same thing with attempting to wire up an event for a...
0
7420
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...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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...
0
6003
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...
1
5349
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...
0
3476
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...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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
1
1033
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.