mvc

pass datatable to the mvc view

I was reading: http://stackoverflow.com/questions/2794831 But I have give a compilation error: CS0246: The type or namespace name 'DataTable' could not be found (are you missing a using directive or an assembly reference?) How do I fix this? ...

ASP.NET MVC - Keeping a controller thin (too many action methods)

I'm working on my first real ASP.NET MVC project and I've noticed that the controller I've been working in is getting rather large. This seemingly goes against the best practice of keeping your controllers thin. I've done a good job keeping the business logic out of the controllers. I use a separate layer for that. Each action primar...

Dynamically modifying DataAnnotation Attributes

I have a simple integer property in a display model. We'll call it "MaxDays". I'm building an MVC app, and I've got the standard set of display and validation statements which will make use of the DataAnnotation attributes attached to the model: <%: Html.LabelFor(x => x.MaxDays) %> <%: Html.TextboxFor(x => x.MaxDays) %> <%: Html.Valida...

How do I use MVC HandleError attribute with JQueryUI Dialog?

I have HandleError attribute working normally, however: I have a jqueryui dialog that displays a partial view. If i generate an error in this action the dialog just remains blank and no redirect to the Error.aspx page. What do I need to do to get this to work? ...

Rails RESTful controllers vs. view specific controllers

This design question needs a bit of context, so please bear with me. I currently have three models that go something like this: class MyItem < ActiveRecordBase has_many :my_list_items ... class MyList < ActiveRecordBase has_many :my_list_items has_many :my_items, :through => :my_list_items ... class MyListItem < ...

help using jquery .ajax() method to pass aggregate data to mvc2 action

Hi, I'm trying to use the jquery ajax function to post to a MVC2 controller action, but my parameters include an array of a (simple) custom class and the action is not getting the data correctly. Client: var element1 = { FirstName: 'Raymond', LastName: 'Burr' }; var element2 = { FirstName: 'Johnny', LastName: 'Five' }; var var2 = [el...

Designing an MVC (web) application from scratch – What Are the basic (necessary and optional) components I should be aware of?

Hi, I’m about to write quite a big web site that will basically be a forum, divided to (many) different subjects and allow users’ score. I’ll be using MVC, so I (“naively”) asked this question about how to partition the Model portion  of MVC, which is likely to be very large. Two things I realized from the answers I got: I really do...

Handling Forms with Relations in Kohana/MVC

This is a question I had about working with the Kohana framework, though I imagine that this is something that could apply to MVC frameworks in general. Let's say I have 2 objects/models, an animal object and a farm object, where an animal belongs to a farm, and a farm has many animals. I have a form for creating new animals, and I want...

Using Zend_Config INI or XML with dynamic data

I have such an array for rendering TableGear: array( "database" => array( 'username' => $this->config->resources->db->params->username, 'password' => $this->config->resources->db->params->password, 'name' => $this->config->resources->db->params->dbname, 'table' ...

What is the best practice for restricting specific pages to logged in users only in Codeigniter?

I have created a sign-up and login for my website and all validation works fine for both sign-up and login. After user provides valid credentials he/she is logged into the member area with a welcome message that says Hello first_name last_name.. basically first name and last name is grabbed from database. Any what I want to do is restri...

Where is the best place to define validation for a field?

A name field needs to be verified as starting with a capital letter and not being allowed to take a number. I'll do this with regular expressions. Implementing the MVC pattern. Should I have the controller send the value that was input to a checking class and send corresponding error msg's back to the UI and after checking then call t...

MVC: Are Models and Entity objects separate concepts?

I asked here a while ago for some help in understanding MVC, since I'm very new to the topic. I thought I had a decent understanding of it, and this is documented in a blog post I wrote recently on the subject. My understanding basically boils down to this: Controller: Determines what needs to be done to fulfill a request, and utilizes ...

ZF: Extend modules indexController, or run init() in indexController

Hi, I was thinking about extending all my controllers from the indexController. I have in the index controller a init() function that does alot of stuff. This is not executed upon fooController request. I allready have a registered a viewSetup plugin. And this is executed on all requests and thats just fine. My problem is a have blog ...

Is this a good way to structure model on an MVC application?

Hi, This is more a "Am i doing it right?" question. I am using a MVC framework ( Zend Framework ) and was wondering if this is the best way to structure a model. In this case i have an user groups model and, after coding for sometime, i realized that on my controllers i was repeating some stuff like a query to return visible groups. ...

How do I pass information my a controller to a view in PHP (no framework)?

Using PHP, If I have a model (a class) where I various queries, whatever I need, and in my controller, I use myModel = new CustomerModel(); and later in the controller, say I call myMyodel in the controller (I know looks like codeigniter but I am not using a framework) to: $data['query'] = myModel.OrderByLastName(); how do I pass that ...

Can I send instance variables to Tequila (.jazz) JSON Parser? (Ruby on Rails)

I am using the great Tequila-JSON Parser ( http://github.com/inem/tequila ) in an Web-application, to render more or less complex JSON server-replies. More and more the JSON-Templates (.jazz) are growing in somehow real "views". I am trying now, to get an instance-variable from the according controller, into the .jazz template, but this ...

.htaccess to change URL

So i have a mvc system setup but it does not generate search engine friendly urls. A typical url is in the format: http://sitedomain.com/class/classMethod?parameter=valueA?parameter2=valueB This is what i need to have: http://sitedomain.com/class/valueA/valueB/ My .htaccess actually modified a part of the url already but i dont kn...

I Need Help Understanding Zend Framework (MVC) Header and Footer Best Practices

I'm new to MVC and Zend Framework and I'm working on a project, mostly on the front end. I'm trying to get a sense of what are best practices. Currently the footer and header are setup through several scripts, one that is a giant XML file of all the content on the website (I think to make the website international friendly, things are w...

Magento addFieldToFilter: Two fields, match as OR, not AND

Hi All, I've been stuck on this for the last few hours. I got it working by hacking a few lines in /lib/Varien/Data/Collection/Db.php, but I'd rather use the proper solution and leave my core untouched. All I need to do is get a collection and filter it by two or more fields. Say, customer_firstname and remote_ip. Here's my (disfunctio...

javascript object System.Collections.Generic.List`1[System.String]?

In MVC, is it possible to pass an array of string (List<string>) from C# code to viewdata and then retrieve the value in the view? e.g: C#: List<string> names = new List<string>(); names.Add("a"); names.Add("b"); ViewData["names"] = names; MVC view: <script type="text/javascript"> var nameList = '<%= ViewData["names"] %>'; </script>...