I want to show Categories of Products I test two approaches :
1.
public ActionResult Index()
{
NORTHWNDEntities _db = new NORTHWNDEntities();
IList<ProductViewModel> pList = new List<ProductViewModel>();
foreach (var p in _db.ProductSet.Include("Category"))
{
ProductViewModel p1 = new Pro...
Hi Guys
I'm doing an ASP.NET MVC application and some of my Action Methods and other Extension Methods need access to User data. The code I'm using to get the user is:
this.currentUser = (CurrentUser)HttpContext.Session["CurrentUser"];
//and in the extension methods it's:
CurrentUser user = (CurrentUser)HttpContext.Current.Session["C...
I have a dropdown list in an MVC view. On selection change of dropdown list I want to call specific action method in the controller.
What I have done on view is this :
<%=Html.DropDownList("ddl", ViewData["AvailableList"] as SelectList,
new { onchange = "this.form.action='MyMethod';this.form.su...
Hi,
I'm a LOB .NET applications developer that would like to do some www consumer facing web site development for small business, along with internet marketing. Typically I need just a simple 5 page layout 'home', 'about us', 'contact', 'faq', etc... But with flexibility to expand onto it if needed.
I guess my question is - are there a...
I would like to implement the repository pattern, having my domain classes being independent from my repository implementation.
but maintain my domain classes -on schema updates using EF for example- is really expensive.
Do you know someway to automatize domain classes updates based on the ORM classes? -using T4 templates or something ...
Hi,
I'm 3 days into learning MVC for a new project and i've managed to stumble my way over the multitude of issues I've come across - mainly about something as simple as moving data to a view and back into the controller in a type-safe (and manageable) manner. This is the latest.
I've seen this reported before but nothing advised has s...
I am experimenting with using xml as a database for small CMS, like gallery or staff profiles
etc
however being all subsonic minded i am stuck on how i bind my xml document to a modelclass
so that i can then use that class for strongly typed views:
here is my model class:
[XmlRoot("employee")]
public class EmployeesModel
{
[Req...
What do you think? should your DAO return an IQueryable to use it in your controllers?
Thanks in advance
...
Before I ask my question: I just started ASP.NET MVC, so an advanced answer will maybe hard to understand ;)
I'm having 3 tables (I'll add just a few of the fields below)
Shops (ShopID, Name)
Products (ProductID, Name, ShopID)
Comments (CommentID, ProductID, UserID, CommentText)
Now what I want to do is this:
www.site.com/Shops
...
I'm working with Visual Studio 2008 SP1 and ASP.NET MVC v1. When right clicking on a view I do not get the option "Convert to Web Application" that I would need to generate code behind .cs classes. I see that option for the actual project and folders, but not for views (aspx files). I've checked the ProjectTypeGuids to have the "right" (...
I need to run a Controller Action from my Console Application that reference to my MVC App.
The reason behind this is because there are some special Action method that i cannot just simply copy to the new application. (Because of the control things)
So I just want to ask if there could be any way to call a controller action method fr...
I'm a bit confused by the behavior of ASP.NET MVC with it not changing the value of a dropdown list after a POST. Can someone explain how to do this.
First of all I have a model that looks like this:
public class Test
{
public int OneID { get; set; }
public IEnumerable<SelectListItem> OneList
{
get
{
...
I've never had this problem before, I'm at a total loss.
I have a SQL Server 2008 database with ASP.NET Forms Authentication, profiles and roles created and is functional on the development workstation. I can login using the created users without problem.
I back up the database on the development computer and restore it on the product...
Hi All,
I have a controller call DefaultController. Inside this controller i have views for what would be the equivalent of static pages.
The URLs look like www.site.com/Default/PageName
Is it possible to create a route that would format these URL like:
www.site.com/PageName
I want to avoid creating controllers for each of these. An...
It appears that if you just use Html.DisplayFor(model => model) with no templates for a Details view, the resulting markup will look something like this:
<div class="display-label">first name</div>
<div class="display-field">Dan</div>
<div class="display-label">last name</div>
<div class="display-field">M</div>
<div class="display-label...
I know S#arp architecture is built for ASP.NET MVC. But I'm wondering if it can be used in classic ASP.NET (WebForms) or even desktop applications like WinForms or WPF.
Thnkas a lot.
...
source code...
Thing is, if i specify required metadata using fluent modelmetadata provider like this=>
public class Foo
{
public string Bar { get; set; }
}
public class FooModelMetadataConfiguration : ModelMetadataConfiguration<Foo>
{
public FooModelMetadataConfiguration()
{
Configu...
How do you do a HTTP 301 permanant redirect route in ASP.NET MVC?
...
Hi,
I'm looking for some advice on storing views in a data-store (database, file, other) and display them based on routing data, all using ASP.NET MVC 2 and ASP.NET Routing.
For example, I'd like to be able to display different views based on the following route data:
/{country}/
/{country}/{area}
But in the same vein I'd like to di...
I have several mvc applications on the same domain, each have their own directory.
mydomain.com/app1
mydomain.com/app2
etc..
When using Url.Content() and Url.Action() when at the root level, 'app1' part is repeated twice in the urls.
// code used to generate the links
<%= Url.Action("tetris", "Apps") %>
Page Url: mydo...