asp.net-mvc

Pass HTML from controller to view

Hello guys, I've made a structure to retrieve from database, based on the role given, to return menu itens. Now, I need to make a recursive method to render this HTML in the controller and pass this HTML to view. But i just don't know how to write native HTML in the controller. Any suggestions? ...

Access to Entity Manager in ASP .NET MVC

Greetings, Trying to sort through the best way to provide access to my Entity Manager while keeping the context open through the request to permit late loading. I am seeing a lot of examples like the following: public class SomeController { MyEntities entities = new MyEntities(); } The problem I see with this setup is that if you...

How to Filter Model with Interface in View

in my view Inherits="System.Web.Mvc.ViewUSerControl<Model.Person>" How can I use an interface to restrict what the view is capable of accessing from the model? is this safe? ...

Difference using UpdateModel and ModelBinding in Parameter

Why would I use UpdateModel here? A. public ActionResult SubmitPerson(Person person) { } B. public ActionResult SubmitPerson(FormCollection form) { Person person=new Person(); UpdateModel<IFilter>(person,form) } ...

Authorize attribute does not preserve post data

In order to preserve post data after utilizing the [Authorize] attribute on a controller method, which then redirects the user to a login page, which then upon successful authentication redirects the user to where they were intending to go -- how would this be done? The original form submission is not relayed by default. A response to a ...

Is there any good open source ASP.NET application using MVP pattern

Hi All, I'm trying to upgrade my existing web forms application to upcoming framework and rewriting couple of workflow as per the new business requirements. I want to introduce TDD based development in this project but after some investigation found that ASP.NET MVC will not help me as my web existing application is using lots of Infra...

Passing model to layout in MS MVC.

In views i`m passing model strongly typed way like this: System.Web.Mvc.ViewPage<HomeModel> And then just use it: <%= Model.Greeting %> How it would be possible to use strongly typed model in layout? Without strongly typing i would probably add necessary data at controller factory, then use it through (LayoutModel)Viewdata["La...

Replacing Entity in LINQ

I'm using an Edit View in ASP.NET MVC and after an edit it returns the Edited Entity back. What's the best way to get the edited values back to the databse. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, Movies EditedMovie) { var orginalMovie = _db_linq.Movies.First(e => e.Id == id); if (!Mode...

MS MVC login widget.

Context In LAYOUT, i got 2 input fields and submit button. If user authentication is successfully, i want to redirect him somewhere, if not - i want page to be updated with some validation text. Problems Cause widget is supposed to be located in layout, i dont know which is current page, therefore - cant get back on failed authenticat...

ASP.Net MVC - route object id == title - how to deal with duplicates?

Web pages have moved to use URLs like: //weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx i.e. they include the title of the page in the url rather than having some coded id. I understand that this is useful for SEO, and also for users in finding the correct page where they wish to type in the...

How to handle relationships to users from other tables in ASP.Net MVC?

At the table level I'm setting aspnet_User.UserID as foreign key of UserID in the other tables (like Posts.UserID, so each post has an owner). Is that the way to go? When I create the LINQ to SQL model, should I include the aspnet_User table? When I create a post (record in the Posts table, a Post object), how do I set the relationship...

Use different updatetargetid based on view

I have a web page which display a list of items in a HTML table. Above the list is a form which allows the user to add a new item to the list via AJAX (using Ajax.BeginForm). When the data is posted to the controller via AJAX I add the new item to the database backend and generate a new table row via a Partial View which then gets appe...

Change type of ViewData in extended controller

I created my own CustomController base class that inherits from Controller. Likewise I created my own CustomViewData that inherits from ViewDataDictionary. The CustomController class has a ctor that accepts a CustomViewData as parameter. All my controllers inherit from CustomController and pass in their inherited CustomViewData. Now I w...

MVC, Dynamic routing, Unity, Determine if current controller exists in global.asax

What I'm trying to do is dynamic routing for my application. For instance, in Application_BeginRequest() I want to get the current controller and determine if it exists. If not, I want to add a set of routes that override the default routing so that my url looks like this mysite.com/term from database But, if the "term from databas...

Using TinyMCE with ASP.NET MVC

I have TinyMCE working great in my ASP.NET MVC app except for the spellchecker. I followed this article but when I try to use the spellchecker it gives me an "Error: No Response" message. Any ideas on how to resolve this issue? Thanks in advance!! ...

Model dissapears between filter attribute OnException and Master

Right before I return from my OnException in the mvc contrib's Rescue filter I can see the filterContext.Result.ViewData.Model is filled. Then I return, pass a bunch of non-steppable code and the next thing I can see I'm in my master where my ViewData.Model is null. any ideas? ...

Unit Testing the Web GUI

Recently i heard a dicussion in which TDD was the hot buzz word. Now acc to one speaker that to test your behaviors you need to use MVC but on the other side its been said that TDD is an approach which can be adopted in any environment (as the discussion sorround between ASP.NET MVC or Webforms). The other guy claimed if you put your beh...

ASP.NET MVC how to pass parameters

I'd like to have some hidden inputs on View A.aspx and pass the values to Controller. One of the values is a bool, and another one is a char. How can I get those hidden input values in Controller? ...

Dynamic (Runtime Generated) Forms in ASP.Net MVC

This is a general design question: How would you implement a dynamic (runtime generated) form in ASP.Net MVC? Here's the situation: A site admin can define form parameters (fields, type of fields, validation) with a GUI (MVC view). As needed, the runtime generates the form for the end user based on the admin configuration. I'm assu...

jQuery selector not working within jQuery event

The following code produces function (value) { if (value === undefined) { var elem = this[0]; if (elem) { if (jQuery.nodeName(elem, "option")) { return (elem.attributes.value || {}).specified ? elem.value : elem.text; } if (jQuery.nodeName(elem, "select")) { ...