I am working on the following form: This is a smooth popup, I make it appear through ajax using:
$.get('/UsuariosEmpresa/Create/', function (data) { $("#AltaUsuarioProtectiveLayer").fadeIn("fast"); $("#PnlAlta").html(data); });
What is great. And the View for create has the following code:
[Code]....
By now I have this two Save Buttons, Save and btnGrabar, just to test. When I use Save it is sending all the information, but not the values for the "Grupo" and "Empresa" dropdownlists. I am trying to use an Editor Template, but I don't know if is the best way, or is better to make in another way: 2 pages, one for create and one for edit. I have the following ViewModel that I try to use here:
[Code]....
And the dropdown list are in the editor template in this way, they are relation dropdownlist so depending on the Grupo=Group will show the corresponding Empresas=Companies:
[Code]....
And there is the problem I believe. The db diagram for this part is the following: The question are:
a- What is the best way to do this? b- Is ok to use a template? c- How should I send the information to save correctly the id_Empresa value? d- Is ok to use the ViewModels or is better to send all the values as $.post parameters? e- Is ok the way I cascade the dropdownlist?
I have been searching for this answer and can't seem to find anything, but with EF4 I want to create a base model and put in our 'foundation' and any new project we create if we need to add custom tables to that sites db is it possible to add a model with just those specific tables and link it to the model in our 'foundation' I can't seem to find a good resource on something like this and this seems to be like it would be a normal thing to have a reusable base model and a separate one for any one off's
How do I display more than one model per view? The above line limits me to only display UserProfiles. I want to also display other models, like UserJob and etc....how would I go about doing so?
I created a model via adding an ADO.Net Entity Data Model (.edmx file), which brought in all my tables from my database. Is it possible to add validation attributes like [Required] or [Display] to a model created like this? Otherwise, the only alternative I can see is to hand-create a model class with public properties where I can annonate them with the attributes I need.
I want to use RenderPartial twice in my view with different models associated. The problem is that some properties are present in both models (nickname, password). They have no prefix, so even the id's or names are equal in the output. Now, if I have model errors for nickname or password, both fields get highlighted.
I'm trying to develop my application and I've got a master page where I'm planning to create a div container, where my "news" will be loaded from my database and will be shown always on a main site. Then inside of the main placeholder I'm planning to load some extra data too from my database... and there's the question: how to solve that ? is there any possibility to pass a model to a master page ? or two viemodels to a view page inside the main placeholder on my page ? (one with news, and other containing some other data).
In some of the classic descriptions of MVC, the Model notifies Views via the observer pattern. It seems to me that this doesn't happen with ASP.NET MVC, and so one of the fundamental relationships between Model, View, and Controller is missing.
And the the partial view "Person" has an other model:[Code].... If I press the "Submit-Button" on the first view I get to the follwing controler: [Code]....
I've half written an app which has just one model for adding and editing a particular entity.I am trying to embrace modelmetadata and where possible reduce my form code to just calls for EditorForModel. One of the key issues I am having it managing the differences between a add and update scenario.
Take "User" editing for example, in an Add scenario I want "Password" to be a required field, in an update scenario I dont' want it to be a required field. The model-centric approach would have me create two models, one for adding and one for editing. My edit model wouldn't have the Required attribute on the Password field. My feeling is this is going to create a bit too much plumbing.
Besides having a rather massive amount of automapping going on there is another more irrititating issue. Strongly typed views. I could... maybe see my way to having a different model for create and edit, using inheritance i could.. maybe mitigate the amount of code required. What I can't abide is having to have two seperate views, as I have already coding myself into a wall with strongly typed views I couldn't share add and edit (based on my understanding) scenarios with one view.
So anyway I was wondering what other peoplle are doing to manage this? Working with an outsourced (Indian) developers it would be great to make use of EditorForModel as I want them writing as little code as possible.
I've a product model that contains a list of description models. Every description model contains some string values because every product can have a description for every language. Here it is a semplified version of my models:
[Code]....
So my view to insert a new product is like this:
[Code]....
And my PartialProductDescription view is like this:
[Code]....
Now, the views are perfect. With some Jquery UI I have a form with all the product properties and a tab panel with the language descriptions.
Unfortunatelly my POST action with the firm public ActionResult ProductNew(ProductModel model) has all the model property InternationalDescriptions that contain 2 empty models. So if I write something in the form in the first description textarea, model.InternationalDescrtiptions[0].Description is always empty.
So, how I can tell to MVC to take description textarea values and put them in the model?
I have one view page.now what i want to do,i want to bind two models to same view.
I have to bind two different models to single view.
I have bind view with storngly type with Department model First display all the Department, now on click of Department i have to show the Courses associated with that Department.
I am having two models User and Address. In the create User view apart from the user information, the user can add one or more addresses to himself. So is there a way to do model based validation for multiple models in the same time ?
I have a requirement where i need to use Master Class (a class in my model) as ViewMaster's Model and the View using MasterDetail (another model). i use them in this form and View in this form
The model item passed into the dictionary is of type 'Models.GeneralMasterModel', but this dictionary requires a model item of type 'Models.MasterNavigationModel'.
my requirement is like this, the viewmaster is of three column layout, first column showing an IEnumerable containing some navigation links, the third column contains an IEnumerable of MasterDetail class depending on the Master object clicked, and the center column is the content place holder for displaying child views (for editing, displaying selected masterdetail). this view's model will be deferent for each masterdetail selected.
How do you handle multiple models in a view?. I have 2 tables. Member and MemberAddress
Member class contains Collection of MemberAddresses since a single member may have a billing and shipping address:
public class Member { public virtual int MemberId { get; set; } public virtual string Username { get; set; } public virtual bool IsActive { get; set; } public virtual bool IsSame { get; set; }
Are there any good tutorials that show how to build and maintain entity models from scratch manually. The visual builder it comes with it quite buggy and pretty much useless. If I make a change in the database and then try to update model from database in the .edmx file, it does not work properly (like making a field Nullable). I have to completely delete and then re-generate that file again and I am not going to be doing that every single time I make a database change so I need to know how to build and maintain these classes manually. Note that I need the C# version, not VB.
I have a MVC3 solution named "SampleProject". I have 4 projects in the solution.
The project names of the solution are
SampleProject.Data (holds entity classes, DAL classes, and filter classes) SampleProject.Service (something like BLL in standard ERP) SampleProject.Tests (test project) SampleProject.Web (holds controllers and views)
I am calling the Service classes from my controllers. The service classes are calling Data classes and performing the database operations.
I have done create, list and details part. Now I stucked in Edit part. None of the examples (NerdDinner,MVCMusicStore etc) using my architecture. In the provided examples, they are just using built in UpdateModel method which I don't want to use. I want to manually get the model object from my view and send it to my Data layer for update.
I'm trying to learn the ropes of ASP.NET MVC and so far so good. One thing which I haven't seen addressed yet is the 'right' or most elegant way to pass multiple data models to a view. To help put the question in context, take this example: Say I was making a blog. When I log in I want the home screen to display a list of all new unapproved comments, as well as a list of recently registered users, and a list of the most recently submitted blog posts.
Most discussions I've seen suggest strongly-typing the view page so it can be called with something like "return View(RecentComments)" and iterate through the comments in the view, or to cast the data model like "var NewUsers = (MembershipUserCollection) ViewData.Model". What I'm ideally after is the 'right', or at least a 'right-enough', way of passing multiple models while still maintaining appropriate logic separation.
I used the auto generated models to use my existing SQL server in a new website.in some forms I use rich text editor (CKEditor) so I added [ValidateInput(false)] to those post back actions. but that is a bad solution 'caus I have lost of other from items which needs validation. I came across a potential solution to that using [AllowHtml] which I need to add to the model properties. I tried that:
[Code]....
but that is an error "type or namespace couldn't be found.."any ideas about where the [AllowHtml] attribute should be?
I am reorganizing my MVC app into a Models project and a Controllers project, and then the main application as a project. So, everything is working good so far except. Whenever I go to "Rebuild" my controllers project, I get this error: Controllers.AccountController.Initialize(System.Web.Routing.RequestContext)': no suitable method found to override.
Keep in mind that AccountController.cs was automatically placed in my application by Visual Studio, and this was all working fine when the Controllers were within my main project. I think it might have to do with the ASPNETDB.MDF file that this AccountController.cs file references to authenticate users as they log in, since this database stayed within my main project and didn't follow the Controllers project.
Here's the Initialize method on my AccountController: protected override void Initialize(RequestContext requestContext) { if (FormsService == null) { FormsService = new FormsAuthenticationService(); } if (MembershipService == null) { MembershipService = new AccountMembershipService(); } base.Initialize(requestContext); }
I am trying to load a usercontrol with its own model, how does this work in practice? What I want really is to click on a button in a View which opens up a UserControl in the center of the page but there will be no sending my model to it because the model used on the page does not contain what I want it to display in the control (More detailed, the page is a memberpage and the uc is an admin page for approving images sent by other members). I've messed around with Inheritance but not really gotten any good results from that perhaps im doing it wrong). This is how it looks today:
The Model
[Code]....
The Controller
[Code]....
The Link
[Code]....
The UserControl
[Code]....
The Error
What can I do differently to make this thing work properly?