asp.net-mvc

asp.net mvc partialview

It seems that my understanding of the use of partial views is not quite right. I am trying to add a partial view which builds from a database and use the partial view within a master page. Using the NerdDinner project (wich is great for mvc) I have added the following: Views\Shared\dinners.ascx" : <%@ Control Language="C#" Inherits="...

UrlHelper extension method call encoded not executed

I created a simple extension method for the ASP.NET MVC UrlHelper. It takes no arguments as its job is to look up the name of a stylesheet file from the configuration and return a url to the stylesheet. The extension method looks roughly like this: public static string SiteStylesheet(this UrlHelper urlHelper) { var scriptFilename = ...

Using MVC Html.RadioButton in Views

I have a number of dynamically created fields on the views. Lets say Car Payment [1] [2] [3] House Payment [1] [2] [3] CC Payment [1] [2] [3] In my controller I want to see what values the user has selected for each one but I find that using the FormCollection I only get back "Car Payment", "House Payment", and "CC Payment". I do not...

jquery script executing but not setting css for .show

Hi, I have jquery code that is being reused by a repeatable partial view on an asp.net mvc page but the script is not executing as I expect it should. The scenario is not that complex, I have a page with multiple reviews for an item, and users who are logged in are allowed to 'vote up' or 'vote down' a review via a thumbs up/thumbs down...

Asp.Net MVC Themes, how to?

Hello, I have a ASP.Net 2.0 site and want to translate it into MVC paradigm (I'm new to this), but starting from Zero. I have some themes in my old site, but reading here and there, it seems like Themes doesn't fit well into MVC paradigm. The question is: What is the best practice in MVC for building a Themed user customizable site? C...

Iterate through an IList

How do I iterate through an IList collection and return only n number of records? I am trying to implement paging using an IList object. ...

not having to encode url

Say I have this url "/my#stuff" I am using asp.net mvc and when I try to goto this page it takes me to just "/my". The "#stuff" part has been removed. Now I can get it to work fine if I encode the URL like so "/my%23stuff" since %23 decodes to # However, is there a way I can get this to work without having to encode the url? I'd like...

ASP.NET MVC: Does JsonResult method require the Bind attribute?

I understood that this Bind attribute was not necessary, but JSON type is not binding without it. What am I missing here? I am running RC1. Edit: this is supposed to work: public JsonResult Index(Person person) { do something with person. } But it won't work for some controller actions unless I do this: public JsonResult Index(...

asp.net mvc: How to pass anonymous type to UserController?

I tried the following but doesnt work: <%Html.RenderPartial("userControl",new {personID=Model.ID, name="SomeName"});%> In the usercontrol I have a hidden field in an ajax form to which I assign personID. It wont compile, the hidden id is not recognized. ...

How do you get jQuery intellisense working if you've implemented a Url Helper extension to get the URL of your script files?

I have implemented the Url Helper extensions that Kazi Manzur has suggested in his MVC best practices guide here My Url Helper extension method to get a script file: public const string ScriptDir = "~/Assets/Scripts"; public static string Script(this UrlHelper helper, string fileName) { return helper.Content(string.Format("{0}/{1}"...

ASP.NET MVC - Caching Forms

More out of curiosity than anything. Do you think it'd be good practice to cache form pages? I've got a form that has a dropdown box that is populated from a rather hefty SQL call and takes a bit too long to load (from my shared hosting site). It's a simple form that when submitted just saves a bit of data to the database. I'm thinkin...

JQuery and ASP.NET AJAX differences in MVC

Hi Looking at the new ASP.NET MVC framework it comes with javascript files for both ASP.NET AJAX and JQuery. Can someone explain what ASP.NET AJAX gives me that JQuery doesn't? Do I need to use both and can you give me examples where I would/would not need to use both? I've used JQuery on plenty of non ASP.NET projects (PHP and proto...

ASP.NET MVC Problem of creating strong-typed view

I'm learning ASP.MVC now. I got some problems of creating strong-typed view. I added Entity Data Model to Models, and then I tried to add a strong-typed view based on the Entity Data Model I created. But I cannot see any class in "View data class" in "Add View" dialog. Did I miss sonmething? ...

Is there any way to display image in client browser without uploading it to server?

I am writing a simple "Book" create page in ASP.NET MVC. User can create book by filling title,year etc.. and selecting a cover image. When user press "Create" button Form sends image and data to Controller action called "Create" then I save image to disk and data to database. But I want to display image when user select image by file...

How do I create a MVC 'Wizard' similar in functionality to Webforms Wizards?

I'd like to create a wizard in ASP.NET MVC similar to the wizard control functionality found in ASP.NET webforms. What is the best way to do this? ...

How to load an xml file from the model when the ControllerContext is null in ASP.Net MVC

Hello. I have a base controller abstract class, which my other controllers inherit. This class needs to load a local xml file in order to create some buttons for the master page. Given that the ControllerContext is null at this stage, what is the best practice for loading the file? (When running on the webserver, I get the following erro...

Stored Procedure Multiple-Table Output With LINQ and ASP.NET MVC

Quite often our systems call stored procedures which output multiple tables worth of results. Previously we used XML outputs to get each table and relate them correctly using XSLT. If I were using ASP.NET MVC with LINQ calling a stored procedure, how do I get each of the tables and then output the data as necessary? ...

Why is google bot getting NullReferenceException when crawling my site?

I have installed some error logging onto my ASP.NET MVC site and I have been getting a lot of NullReferenceException errors when google crawls my site. But when I go to the URL that generated the error there is nothing wrong? Why would this be happening? Why would the google bot be causing an error? ...

Is there an ASP MVC equivilent to JSTL tags?

Are there any libraries that support JSTL style coding in an ASP MVC view? I much prefer <c:forEach var="c" items="${Customers}"> <c:out value="${c.Name}"/><br/ > </c:forEach> to <% foreach(Customer c in customers) { %> <%= c.Name %><br/ > <% } %> ...

attachment property in several models

Hi! I am using ASP.NET MVC + LinqToSQL. There is attachment model in my application. I need <IEnumerate>Attachment Attachments in several models. I don't wasn't to create different attachment models for different parent classes. Is there simple way to do it? ...