asp.net-mvc-2

MVC - SQL Session State vs Storing values in db

Reading conflicting opinions on using SQL session state vs custom db table in MVC to store user data across page requests? What are the advantages and disadvantages to each method? Why should I pick one method over the other. So far it seems a custom db table is the best solution because it doesn't time out, plus it would be strongly t...

ASP.NET MVC 2 Unit Testing Stange Errors

I am working through the book Professional ASP.NET MVC 2 and I am trying to get the unit testing in chapter 1 to work correctly; howver, I am getting some very strange errors. There are two projects in the solution: NerdDinner, and NerdDinner.Tests. In the NerdDinner Project I have the following interface: IDinnerRepository.cs //... ...

MVC 2.0 Post Form to action instead of redirect to action

I am using T4MVC to redirect to another action return RedirectToAction(MVC.MyController.MyAction());. In result it is doing get request. Is there any way to make post request from controller. I want to keep all the same but only make post instead get. I cant find any methods for that. I found one post helper here http://geekswithblogs....

Category is special word in ASP.NET MVC2? So how can I use something else?

Hi all, I have just realized that, by chance, I implemented a category browse type situation in my project: // GET: /Category/Browse?Category=Fruit public ActionResult Browse(string category) { ... } It turns out this is special case and there must be something behind the scenes. My next one I want to implement something like /...

MVC: Html.DropDownList(...) question

Hello community, I create a List with 11 values. The first element contains some text ("Please select ..."), the second is "0", the third is "1" and so on ... Note, that the 6th element contains "5" (five) in the "Text" and the "Value" property. The 6th element is the only one where the "Selected" property is set to "true". This works...

Method Attribute with param from method?

If it matters, this is in ASP.NET MVC2 - how do I do this - how do I apply the "id" parameter to the attribute? This following syntax obviously does not work :) [AuthorizeProject(ProjectId = id)] public ActionResult Browse(int id) { // Stuff return View(); } ...

ASP.NET MVC 2 & Dynamic JavaScript

Hi, I have an unordered list that when an item is clicked it displays several images using the Fancybox JavaScript plugin. I am trying to convert this to ASP.NET MVC 2 and I want to dynamically pass the Image Paths and Title etc. to the JavaScript so that they are not hard coded. HTML <ul> <li><a href="DisplayImages();" title="...

ASP.NET MVC 2 - Property validation

I'm new to MVC and have a question regarding validation. Is there a way to dynamically set the Error Message? For example, how could I achieve the following (ignore the hardcoded 50, this could come from the Web.config or specific to the current logged). [MetadataType(typeof(DocumentValidation))] public partial class Document { pub...

MVC custom model binder issue

Hi, I have a textbox in my view that i want to receive the value as a List of strings. As example, if anybody enters: tag1,tag2,tag3... receive a List with 3 elements. I did a custom model binder, but im still receiving from the post the string instead the List. This is the stuff that i did: This is my Model: public class BaseItem...

DropDownListFor not binding on Edit View with repeating items (List<T>)

Here is the thing. I have an Edit view, which doesnt bind the dropdowns' value when I open it. [NonAction] public List<SelectListItem> VraagType() { List<SelectListItem> l = new List<SelectListItem>(); SelectListItem a = new SelectListItem(); SelectListItem b = new SelectListItem(); a.Text = "Mee...

Cannot call other action

I'm studying ASP MVC, and developping SportsStore (Create/Edit feature). When Create a product, Create action will view a Edit view, but when press Sudmit, it call action Create (Post), althrough I will set it call Edit action: <% using (Html.BeginForm("Edit", "Admin", FormMethod.Post, new { enctype="multipart/form-data" })) {%> ...

Curious problem with the ContentPlaceHolder in the HTML Title tag of the masterpage (MVC2)

Ok, I'm sure it must be a silly mistake on my part, but I can't find where the problem is, and it's driving me nuts. I have a master page, with this: <head runat="server"> <title> <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> - Company </title> </head> It's just the default HTML inserted by VS when I crea...

Need a Gridview to be added in view and also i would need to extended HTMLHelper class to manipulate(Paging, sorting) the Grid

Can you let me know about adding Gridview control / similar control in MVC2 also i would like to have the sorting, paging options to that. Thanks in advance ...

How can i set Default value for HiddenFieldFor In Asp.Net MVC

i am using HiddenFor with model binding which is binding value to it. i want to reset the binded value to zero.How can i do it? i tried this but it is not working... <% foreach (var item in Model ) { %> <%: Html.HiddenFor(model => model.ID,new { @value="0"})%> <% } %> ...

MVC Checkbox 'disable' true issue

I have two controls ControlEdit and ControlView with some inputs and checkbox and two views ReadOnly and Edit, I was using MvcContribn checkbox helper to make checkbox disable I did set attribute disable to true on defaultView(here I am loading ControlView) by default user chant make any changes on that view, then if user click change bu...

MVC Mock HttpContextBase which is used in a helper

I am using a helper in my controllers and in my views that I have found somewhere on the internet. The helper is called like this in my controller "Url.SiteRoot();" How can I get my controller to not throw an Exception whenever the helper is called? I am using MVCContrib and moq for my unit tests. I am thinking of implementing some kind...

Why is Visual Studio Web Server Browsing the directory?

Hi, this could be seen as a follow-up to this SO question here. Now we have moved on more than a year and ASP.NET MVC2 comes along without a default.aspx I must have done something to my project in that when I hit the root, the server lists the directory and does not route through my default route. The Routing seems to be accepted, thou...

Ajax call in JsTree jQuery plugin in MVC

I am trying to get JsTree to work to get a folder view in my MVC application. Everything works fine if I use existing static html ul list in the page view. But I need to get the ul list dynamically, so I am trying the ajax call for JsTree described in the documentation: <script type="text/javascript"> var url; $(document...

jquery load partial view asp.net mvc

i have some header tabs on a basic index.aspx page that uses a masterpage. the header tabs are correctly rendered on the index page from a viewusercontrol (<% Html.RenderPartial("pvHeaderTabs")%>). the problem is i am trying to load other partial views into the index page without any luck. can someone point out what i am doing wrong? ...

Turining An HTML <td> into a link ASP.NET MVC

I'd like to be able to turn rows of an html table into links to controllers. I figured something like <td onclick="<%:Html.ActionLink("", "Index", new {id=item.user_id}) %>"> I'm using MVC 2 Thanks. ...