asp.net-mvc

Generating AntiForgeryToken in WebForms

I have a .NET Webforms site thanks needs to post to my MVC Application which currently sits inside the Webform site as a separate application. The Webform application need to POST some sensitive values to the MVC Application. Is there a way to generate a AntiForgeryToken() in my WebForms Application so it can be passed with the form po...

Is there a JQuery Table plugin that supports an HTML table as an AJAX datasource

I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls d...

how to handle multiple forms on one page?

On one page i have list of questions with diffrent tipe of answers. (texboxes, checkboxes etc) Page is dynamicly generated. I have to store answers in database. What is the best way to do this? multiple forms or something else? it would be great if i could send ajax request after every answer but i don't know how to accomplis that (how t...

ASP.NET MVC: Get an action output within another action

In ASP.NET MVC application I have an action Page() which renders a page (like a wiki page). Now, I have another action RenderPdf() which should collect the HTML output of Page() and use HTML2PDF component to create PDF version of that page. How do I collect the HTML output of one action within another action. Note: not in the view, bu...

Confused about attaching/detaching entities in EF

Hi, Using ASP.NET MVC and Entity Framework, I encounter some attach/detach errors when I need ti write changes to the database. First heres how I get the records from my repository: public PublishedApplication GetPublishedApplication(int id) { return dal.ExecuteFirstOrDefault( context.PublishedApplication.Include("Customer...

How can I handle a dynamically created form submit?

How to handle dynamically generated form submit in asp.net mvc? Form is dynamically created (number, order and type of elements are always different) and i have to handle it (store the data in the database) in the Controller of asp.net mvc (there is no viewstate). Type of input can be everything; hidden fields, radio buttons, check boxe...

FireBug not working with ASP.NET MVC

Hi All I have started a new ASP.NET MVC project and have included the ExtJS library files. This all works fine when built from Visual Studio and i can display various ExtJS objects. The problem however is that FireBug has stopped showing errors in the Console, even when i type nonsense into the code block. Setup is: VS 2008 SP1 FireB...

Two .NET projects, one DB connection string?

I have a .NET solution containing two projects: An ASP.NET MVC project, 'Website' A class library, 'Models' The 'Models' project contains a Linq-to-SQL data-context along with a few partial classes that extend the database objects. The connection string is defined in the web.config of the 'Website' project. However the 'Models' pro...

subsonic 3.0.0.3 MVC2 how to work paging Model.HasPreviousPage not working

HI i wish to have some nice paging for my subsonic project, i am fine with the code behind however i cant find any information with regards to paging on the view side of things ??? i have tried Model.HasPreviousPage but this no longer exists, so am all out of ideas on where to even begin, is there some hidden manual for this stuff so...

Warning: "File '../ControllerName/ActionMethodName' was not found."

We're seeing the above warning on a View's form post... <form action="../ControllerName/ActionMethodName" method="post"> Technically this warning is correct - there is no such file, but as we're using ASP.NET MVC this check isn't really sufficient. This warning isn't stopping our application from working but we have a general "no com...

JQuery DOM manipulation and window.onbeforeunload in Internet Explorer

Hi, I have this code block: window.onbeforeunload = function(){ <% if (Session["DisableExitConfirmation"] == null || !(bool)Session["DisableExitConfirmation"]) { %> if (isDirty) return '<%= Html.EncodeJsString(Html.Resource("profile_unsavedchanges")) %>'; <% } else { %> if (isDirt...

asp.net MVC HTML injection

I have an MVC view which is using a model, and I am after injecting some HTML for additional content which is not part of the model. I don't know the content of the injected HTML or text fields as they will be plugins. How can I pick up the changes to both the existing model and capture the plug-in HTML fields? ...

POCO format in asp.net MVC app.

I am creating a simple aspnetmvc cart application and have defined classes similar to the following: public class Cart { public Guid Id { get; set; } public string Comment { get; set; } public DateTime CreatedOn { get; set; } public DateTime UpdatedOn { get; set; } public DateTime? DeletedOn { get; set; } public ...

Is there a standard model to controller 'ratio' when trying to implement good ASP.NET MVC?

I'm not sure if this question is non-sense or not, please tell me if so. I am wondering do I create my models like one per each table in my database, or do you do one per controller? Is there something I am missing here? From what I read the Model is suppose to be a representation of the real business objects, so would I just want to ma...

How do I get the value in an enum for a particular name?

Basically I'm writing my own version of a 'RoleProvider' and 'AuthorizeAttribute'. I've got an Enum (as a bit field) with a list of all possible roles: namespace myProject.Global { [Flags] enum Roles { Viewer = 1, User = 2, Admin = 4, Superadmin = 8 } } My AuthorizeAttribute works simil...

DotNetOpenAuth - OpenId login redirect hangs when relying party is trusted site

I am using the DotNetOpenAuth MVC relying party sample code (with some cosmetic changes) to integrate OpenId into an ASP.NET MVC application. The code works great except for the following situation: when the relying party (my app) is a trusted site under IE, and I'm hitting that site from any location other then the host machine, the re...

How to return JSONResult without the browser prompting to save the file?

I am new to MVC, and am trying to make a simple site work. I'm starting to wonder if it is really worth it...I could have had this site up and running with "old-school" ASP.Net two or three times already...but that is beside the point ;-) How can I get my controller to return a JSONResult without the browser prompting me to save the res...

How to render an ASP.NET MVC View in PDF format

I'm working with ExpertPDF's Html-to-PDF conversion utility for this question (although I'm open to other libraries if there's sufficient documentation). In short, I have a view that is formatted a specific way and I would like to render it as a PDF document the user can save to disk. What I have so far is a PrintService (which impleme...

Call asp.net Membership class from controller or service layer?

Should I access the asp.net membership class from the controller and pass the results to the service layer, or access it directly from the service layer? I'm torn because on one hand this seems like business logic that should be handled in the service layer, but I don't want to tie the service layer to the web namespace as this might be...

Change default Webdev.Webserver Physical Path on a VS2008 project

Hello. I think I've seen this done once, but I cannot find it again after a long Googling/Binging session! I'd like to create a new ASP.NET MVC project, then create a folder "Web" inside the project, and move all the "web-related" files to inside this folder. The problem is that when creating this folder structure, I cannot simply pres...