MVC2 Development Without Doing Enough Research About The EF4?
Sep 30, 2010
have starting doing a lot of MVC2 development without doing enough research about the EF4. This lead me to a path which I am not happy with. The way that I laid out my project is that my Models are all ADO.NET Entity Framework Models. Each model is representing database able. Today, I attempted to do a LINQ join on entities which belong to two different data contexts. This resulted in a nasty LINQ error telling me that it can't be done. I hate the fact that the only viable way to use the EF seems to create large models.
View 13 Replies
Similar Messages:
Aug 27, 2010
Currently i have membership and roles setup on my site. Now what is my next step to get more specific control.
Based on what i hav now, i have my pages setup so they are visible or not and links not visible and so on. But now on a more detailed level, say im setup as a user. As a user my default permissions is just to view data.. no editing. But say someone was let go, now instead of granting me full access to everything, i need to be able to go in and provide more permissions to the account.
Example:
Admins:
Add Users
Modify Users
Delete Users
Users:
View Users Detail (only the person that is logged in)
Since the the user that was let go was an admin. They had all the other options, but as a temporary thing, we need to be able to add say permission "Add Users" to the individual user account.
To accomplish this type of control, what do i need to look at to accomplish such a setup?
View 3 Replies
Oct 20, 2010
We have a largely asp.net web form team (With some Oracle developers thrown in).
Question 1:
Is it a good idea to start using asp.net MVC which will mean redevelopment of a number of standard controls for not much benefit.
Question 2:
Is it a good idea to hire developers where there most recent skills are with asp.net MVC?
I doubt there is any benefit adopting MVC now, given the 100+ applications in this suite of products, and the maintenance/rework this will cause. Given this, is there any particular reason to hire MVC developers, as they won't be hitting the ground running, which is what I need now.
View 3 Replies
Jul 16, 2010
I am planning to develop a social networking website for student of a particular university with following facilities.
Forum, Blog, Creating profile, creating groups , Adding Friends, managing groups, dating, chatting etc.
Now if I start developing it from scratch, this will take a lot of time..
I couldnt find any CMS which can in developing social networking website.
Additionally, I would like the website to have my own custom design. Also it should have support for AJAX, SEO and integrating third party applications.
View 3 Replies
Sep 13, 2010
How do you know what is better to use for writing new programs? We are now using Access 2007 frontend with an SQL backend and we are going to VB.Net, what would be our next logical step?
View 4 Replies
Oct 8, 2010
i'm trying to encode an url with the code below;
var encodedUrl = HttpUtility.UrlEncode("http://www.example.com");
var decodedUrl = HttpUtility.UrlDecode("http%3A%2F%2Fwww%2Eexample%2Ecom%2F");
I'm working with the google webmaster tools api and this api expects an URL as shown in the decodedUrl variable above. Every single character is encoded there.
When i use the httputility encode function i get the following result;[[URL] How can i use the encoding variable in such a way that every character in the url is encoded?
View 2 Replies
Mar 2, 2010
[HttpPost]
public ActionResult Edit(int id, FormCollection fc)
{
Movie movie =
(
from m in _ctx.Movie.Include("MovieActors")
where m.MovieID == id select m
).First();
MovieActorViewModel movieActor = new MovieActorViewModel(movie);
if (TryUpdateModel(movieActor))
{
_ctx.ApplyPropertyChanges(movieActor.Movie.EntityKey.EntitySetName,
movieActor.Movie);
_ctx.SaveChanges();
}
return View(movieActor);
}
However, I am not sure how to test this, and in general would much rather have the method take a typed model like:[HttpPost] public ActionResult Edit(MovieActorViewModel movieActor) Is this possible? What changes to my MovieActorViewModel class do I need to make in order to enable this? That class looks like this:
public class MovieActorViewModel
{
public Movie Movie { get; set; }
public Actor Actor { get; set; }
public PublisherDealViewModel(Movie movie)
{
this.Movie = movie;
this.Actor =
(
from a in this.Movie.Actors
where a.ActorID == 1 select a
).First();
}
}
The view is typed (inherits ViewPage) simple:
<% using (Html.BeginForm()) {%>
Movie Title: <%= Html.TextBoxFor(model=>model.Movie.Title) %><br/>
Actor Name: <%= Html.TextBoxFor(model=>model.Actor.Name) %>
<% } %>
View 3 Replies
Feb 8, 2011
I tried upgrading the solution to MVC3 in VS2010 by using an upgrader tool I don't know what it does exactly but it didn't work. My "System.Web.Mvc" is not being recognized in my project. Is there anything specific I should be doing with my web.config? I don't quite understand the underlying details about all the places I should be referencing dll's or what "binding" even means and when I should use it inside the web.config So I have to ask, what is the best method for upgrading to MVC3 and what have you done that works?
View 1 Replies
Apr 29, 2010
I've spent the majority of the past week knee deep in the new templating functionality baked into MVC2. I had a hard time trying to get a DropDownList template working. The biggest problem I've been working to solve is how to get the source data for the drop down list to the template. I saw a lot of examples where you can put the source data in the ViewData dictionary (ViewData["DropDownSourceValuesKey"]) then retrieve them in the template itself (var sourceValues = ViewData["DropDownSourceValuesKey"];) This works, but I did not like having a silly string as the lynch pin for making this work.
[code]...
View 3 Replies
Mar 25, 2010
I am trying to figure out how to get the DisplayAttribute in my MVC 2 ViewModel to work with the Html.LabelFor() helper.
Neither
public class TestModel
{
[Display(ResourceType = typeof(Localization.Labels))][code]...seem to work. Localizing the Required Attribute works as expected:
[Required(ErrorMessageResourceName = "Test", ErrorMessageResourceType = typeof(Localization.Labels))]
I am using VS2010 RC. Has anybody got that running?
View 3 Replies
Nov 16, 2010
I have an MVC2 .NET 4.0 app, hosted on TFS 2008 (soon to be TFS 2010) that uses connection strings in web.config to connect to a database on another server. I need to encrypt these connection strings.
As I understand it, I can use aspnet_regiis.exe to encrypt the connectionstring portion of the web.config file, but I have to do it on the deployment machine because the encryption uses the machine name to generate the encryption key.
Now, it seems to me that this represents a problem - every time I deploy my code to the dev server won't it overwrite the web.config file, and need to be re-encrypted? This sort of manual process seems kludgy.
Is my understanding about needing to re-encrypt after deployment correct? If so, is there some way to automate this process? I don't want to forget this or get a new team member who doesn't know the process and have the connectionstring exposed to the world.
View 1 Replies
Jun 28, 2010
For my project, i need to connect to a database who don't support ADO.net by using NHibernate
So, is it possible to make my own model who can be usable by the auto-creation of views of visual studio 2010 ?
View 2 Replies
Mar 3, 2011
I have this code in my view page.
<td>
Mandate Name:
</td>
<td>
<%= Html.TextBox("MandateName")%>
</td>
I wrote MVC2 Validation for this name.
something like this.
//[Validator(typeof(MandateValidator))]
[MetadataType(typeof(Mandate_Metadata))]
public partial class Mandate {
public class Mandate_Metadata
{.........
View 2 Replies
Apr 24, 2010
I've tried this guide: http://mvcsitemap.codeplex.com/Thread/View.aspx?ThreadId=208090I've added dll "MvcSiteMap.Core.dll" i referencesAnd I've added namespaces in web.config: "<add namespace="MvcSiteMap.Core" />"When I'm entering the web page comes this message:
Line 49: </runtime>Line 50: Line 51: <siteMap defaultProvider="MvcSiteMap">Line 52: <providers>Line 53: <add
View 3 Replies
Apr 24, 2010
Again a question about RadioButtons/ RadioButtonList
I've the following Model:
public class SkillLevelModel
{
public long? Id { get; set; }
public int? SelectedLevel { get; set;}
}
I've the following Controller:
public class SkillController : BaseController
{
public ActionResult Index()
{
var skills = new List<SkillLevelModel>();
for (int i = 0; i < 10; i++)
skills.Add(new SkillLevelModel() { Id = i, SelectedLevel = new Random().Next(0,5) });
return View(skills);
}
I've the following code in the View:
<% foreach (var item in Model) { %>
<tr>
<td style="width: 30px" align="center">
<%= Html.Encode(item.Id) %>
</td>
<td>
<% Html.RenderPartial("UCSkillLevel", item); %>
</td>
</tr>
<% } %>
I've the following code in the PartialView:
<% for (int i = 0; i <= 5; i++) { %>
<td align="center">
<%= Html.RadioButton("SelectedLevel", i, new { id = Model.Id + "_" + i })%>
</td>
<% } %>
The problem is that no radiobutton is checked, althought they have a level.
View 2 Replies
Oct 24, 2010
I am trying to use Domain Driven Development (DDD) for my new ASP.NET MVC2 project with Entity Framework 4. After doing some research I came up with the following layer conventions with each layer in its own class project:
[code]...
Currently my Repositories layer holds a reference to the Domain layer.From my understanding injecting a UserRepository to the UserService class works very well with unit testing as we can pass in fake user repositories.So with this architecture it looks like my Web project needs to have a references to both my Domain and Repositories layers.But is this a valid?Because historically the presentation layer only had a reference to the Business Logic layer.
View 3 Replies
Jul 26, 2010
I have combined a MVC2 project with a WebForms project....however I found that the only way to do this was to create a base MVC2 project and then start dropping the WebForms project into the MVC2 project.If I do the reverse .....start with a WebForms project I cannot get the MVC2 functionality to work. For example ....if I right-click and attempt to Add an item.....I do not see the option to Add a MVC2 Area.
Obviously....since the WebForms technology is older ....it is more logical to start with a WebForms and somehow enable MVC2 within the WebForms project.I have read all the popular Internet posts on this topic....Hanselman, etc....and while this may have worked prior to VS.NET 2010 release....I cannot get it to work. As I say....the right click Add/Item/Area is not available in my project after I add the MVC2 references and create the MVC2 folders ...(Controllers, Models, Views, etc)....so I found the safest thing to do was to start from a base MVC2 project.
View 3 Replies
Jan 25, 2010
If I decorate my model with a regular expression + localized string resource, and the ErrorMessageResourceName does not resolve to something on the object, the following things happen:
The regular expression is ignored altogether from a validation perspectiveNo error messages are raised in the MVC application.I would love it if the framework floated an exception in this instance because exclusion of this rule could have far reaching implications.The following is a modification to the ChangePasswordModel.NewPassword property in the stock MVC 2 RC1 project that exhibits the behavior. Note that while the MyResources does exist in my project, the EMResourceName does not exist on it.
[Code]....
[RegularExpression(@"^(?=.*d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$", ErrorMessageResourceType = typeof(MyResources), ErrorMessageResourceName = "InvalidPasswordMessage2")]
View 3 Replies
Mar 31, 2010
It looks like the final release for ASP.NET MVC 2 has been already around for 2 weeks. Unfortunately, I can't find documentation that's intended for MVC 2 exclusively. I've checked Amazon.com (no book yet on MVC2), ScottGu's Blog (only 2 short posts), ASP.NET/MVC website (they've only posted what are alreadi in the ScottGu's blog).
View 4 Replies
Mar 1, 2011
how can i connect mySql to my mvc application
i need a tutorial and all steps to connect to mySQL
View 1 Replies
Jan 7, 2011
I'm making an MVC2 app to manage billing schemes. These billing schemes can be of various types, e.g. daily, weekly, monthly, etc. and all types have their specific properties. My class structure looks like this:
public abstract class BillingScheme { /* basic billing scheme properties */ }
public class BillingSchemeMonthly : BillingScheme
{
public string SpecificMonths;
}
//etc. for other scheme types
I retrieve a billing scheme through the base class using the billing scheme ID, and it gives me an object of the correct type. The property SpecificMonths maps to a database varchar field that contains a ;-separated string of month numbers. I want to split this to an array so I can create a list of checkboxes and I'd preferably do this with a facade property in a viewmodel. I could do it right inside the view but that seems to go against the MVC pattern.
The problem is I can only create this viewmodel specifically for a BillingSchemeMonthly, and I can't cast a BillingSchemeMonthly to a BillingSchemeMonthlyViewModel. I'd rather not implement a clone method in the viewmodel since the entire billing scheme is quite large and the number of properties may grow.
View 2 Replies
Mar 7, 2010
Table Product
Product Id
Product Name
Table ProductSupplier
ProductSupplierId
ProductId
SupplierId
Table Supplier
SupplierId
SupplierName
I have the above 3 tables in my database, ProductSupplier is the lookup table. Each Product can have many suppliers. I am using Entity Framework. Using Web Forms it was fairly easy to display a Product on a web page and bind a repeater with the suppliers information. Also, with Web Forms it was easy to Add new Product and suppliers, the linkage seemed easy.
How do you do this sort of functionality in MVC? In the Create View below, I want to be able to Add the Supplier as well. Is there a better approach that I might be missing here? This is how I did it with Web Forms. Beyond the code below I am totally lost. I can show data in a list and also display the Suppliers for each Product, but how do I Add and Edit. Should I break it into different views? With Web Forms I could do it all in one page.
namespace MyProject.Mvc.Models
{
[MetadataType(typeof(ProductMetaData))]
public partial class Product
{
public Product()
{
// Initialize Product
this.CreateDate = System.DateTime.Now;
}
}
public class ProductMetaData
{
[Required(ErrorMessage = "Product name is required")]
[StringLength(50, ErrorMessage = "Product name must be under 50 characters")]
public object ProductName { get; set; }
[Required(ErrorMessage = "Description is required")]
public object Description { get; set; }
}
public class ProductFormViewModel
{
public Product Product { get; private set; }
public IEnumerable<ProductSupplier> ProductSupplier { get; private set; }
public ProductFormViewModel()
{
Product = new Product();
}
public ProductFormViewModel(Product product)
{
Product = product;
ProductSupplier = product.ProductSupplier;
}
}
}
ProductRepository
public Product GetProduct(int id)
{
var p = db.Product.FirstOrDefault(por => por.ProductId == id);
p.ProductSupplier.Attach(p.ProductSupplier.CreateSourceQuery().Include("Product").ToList());
return p;
}
Product Create View
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<MyProject.Mvc.Models.ProductFormViewModel>" %>
<%= Html.ValidationSummary("Please correct the errors and try again.") %>
<% using (Html.BeginForm()) {%>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%= Html.LabelFor(model => model.Product.ProductId) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Product.ProductId) %>
<%= Html.ValidationMessageFor(model => model.Product.ProductId) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Product.ProductName) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Product.ProductName) %>
<%= Html.ValidationMessageFor(model => model.Product.ProductName) %>
</div>
<div class="editor-label">
<%= Html.LabelFor(model => model.Product.Description) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(model => model.Product.Description) %>
<%= Html.ValidationMessageFor(model => model.Product.Description) %>
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
<% } %>
View 1 Replies
Sep 20, 2010
I want to have two partial views, one for SEARCH and one for SEARCHRESULTS. I want to update SEARCHRESULTS when the "Search" Button is clicked on the SEARCH partial view form. SEARCHRESULTS needs to have the form data fed to it from the SEARCH partial view. I'm not totally sure how to go about this. Can I update the SEARCHRESULTS partial view from my SEARCH partial view's Controller action?
View 1 Replies
Nov 23, 2010
Possible Duplicate: How to create file and return it via FileResult in ASP.NET MVC?
ASP.NET MVC2: How to return a file from a controller? I want to do this so the user can download the file from server.
View 1 Replies
Aug 20, 2010
This works fine: Controller.cs
ViewData["MyText"] = "Hello World";
Index.aspx
<%: Html.Label(ViewData["MyText"].ToString()) %>
But the complete text is not displayed when I add just a dot "." to "Hello World". I thought "<%:" takes care for this but it seams that this is not true... How to solve this? How to mask the dot? Changing "." with "%2E" doesnt work ;-(
View 1 Replies