asp.net-mvc

Asp.Net MVC don't show Index action in url

I would like that the Index action doesn't appear in the url. For example, I would like to see www.mywebsite.com/MyController/1 instead of www.mywebsite.com/MyController/Index/1 Is there something special I have to do in the Html.ActionLink tag or in the global.aspx file ? ...

MVC Dropdown list value not being set

I'm sure I am missing something obvious, but this is driving me nuts! If I specify html options, the value of my dropdownlist doesn't set. In my controller, I retrieve the options for my dropdownlist with: ViewData["Coordinator"] = new SelectList(userRepository.GetIdUserList(1), "ID", "Signature",edCenter...

How to choose a data access method in ASP.NET MVC?

I've been programming in C# 2.0 WinForms for a while now. I'm starting to get into ASP.NET and the new MVC framework and the new features of C# 3.5. I've only read a little on LINQ to SQL but have made a few test apps to try it out. In my WinForms apps, I usually had some sort of data access layer, and wrote all the SQL myself. Of course...

How do I set the page title in an ASP.NET MVC view?

In an ASP.NET MVC view I have the following code: <% Page.Title = ViewData.Model.MyPageTitle; %> and when I step through it I see the Page.Title value changing to the title that I want but when you look at the page's title shown in the browser it has not been modified. It appears that this value is overwritten by something later on. ...

ASP.NET MVC localization

I'd like to use resource file (.resx) to do localization in ASP.NET MVC. My thought is: Make a default resource file under App_GlobalResources folder Make several local resource files under App_LocalResources folder read cookie info to set CultureInFo Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); then, I'd like to u...

MVC with IIS 6

Hi there, I've read a couple of posts on this issue but still can't seem to get MVC working on IIS 6. I've mapped .mvc to aspnet_isapi.dll in IIS but get a 404 when I browse to my mapped URL which looks like this RouteTable.Routes.MapRoute("action", "api.mvc/{controller}/{action}", new {action = "Index"}); I then browse to //localhost...

Why does Html.ActionLink render "?Length=4"

I'm VERY confused as to why this code Html.ActionLink("About", "About", "Home", new { hidefocus = "hidefocus" }) results in this link: <a hidefocus="hidefocus" href="/Home/About?Length=4">About</a> The hidefocus part is what I was aiming to achieve, but where does the "?Length=4" come from? ...

ASP.NET BeginForm() expression syntax

Hi, I'd like to use the expression-based syntax for ASP.NET MVC's Html.BeginForm (e.g. Html.BeginForm<HomeController>(a => a.ActionForSubmit();) for the increased testability it gives you. I'm unclear about what to do where the corresponding action has parameters. For example, I have a login action that is HTTP POST only and has two pa...

Html.DropDownList select value not being set by Model

I have a drop down list like so: <%= Html.DropDownList("SoldTo", Model.SellDealerList, "Select a Dealer")%> I'm populating the list in my Controller with the following code: SellDealerList = new SelectList(repository.GetDealerList(), "id", "name", vehicle.SoldTo); When I debug through the code the selected value on the SellDealerLi...

Which redirect has precedence - the one in controller action or in ActionFilter's OnActionExecuted?

Looks like I'm about to do something weird again... The situation: public ExperimentAttribute { public override void OnActionExecuted (ActionExecutingContext filterContext) { filterContext.Result = new RedirectToRouteResult ( new RouteValueDictionary (new { Action = "Action2",...

How Can I Reconstruct URL/Route in ASP.NET MVC From Saved Data?

My unfamiliarity with the ASP.NET MVC framework and the plumbing thereof has brought me here, and I appreciate the patience it will take for anyone to read and consider my question! Okay, here is the scenario: I have an application that has numerous pages with grids that display data based on searches, drilling down from other data, rep...

Are there any ASP.Net MVC reference applications

Hi, I am trying to learn ASP.Net MVC framework and I was wondering if there were any good reference applications that I could use to learn about implementing ASP.Net as well as best practices for implementing LOB apps. If possible I would like to see a ASP.Net MVC app that uses AJAX too. ...

Using rails or ASP.NET for website on Windows

I need to create a site that interact with some windows applications. Currently this is done through direct calls so I would like these to run on the webserver. This means that the site will have to run on a Windows based system. I have been doing some ruby lately and am very keen on using rails for the site, but have at the same time s...

JQuery - How to get at all the data

I have a paging menu PartialView in my MVC app that looks like: <% if (Model.TotalPages > 5) { int index = Model.PageIndex; int minIndex = index - 2; int maxIndex = index + 2; if (index < 2) { minIndex = 0; maxIndex = 4; } if (index > Model.Tot...

Adding rows to the MVCContrib Grid

I'm developing my first MVC website and I'm experimenting with the few available grids out there. I really like the MVCContrib grid, but I need to implement a standard "Add new record" functionality, and I don't see a clear way to add a single record to the database and grid without having to reload the entire grid each time. I know t...

How can I refresh a ASP.NET MVC UserControl with jQuery?

Hi everyone! I have a UserControl that binds directly to database, that is, it's not rendered by any Action. It works independly. But, from times to times I have to refresh it to get new information from database. I've already worked with refreshing UserControls in jQuery via Ajax, but in all of these cases, I had a Action to make the ...

Adding a parameter to the URL in ASP MVC

I need to have a parameter as part of my ASP MVC URL before Controller and Action: http://www.mydomain.com/company1/Home or http://www.mydomain.com/company1/Clients/Detail/1 (Ideally I would like to have this as a sub-domain like this: http://company1.mydomain.com/Clients/Detail/1 so any answers solving this one is also appreciated) ...

NullReferenceException Problem with ASP.NET MVC Textbox HtmlHelper

I have the following code in a strongly-typed View in my application: <td> <label for="TriageStartDate">Triage Start:</label> <%= Html.TextBox("TriageStartDate", crit.TriageStartDate, new { maxlength = 10, size = 12 } )%> <%= Html.ValidationMessage("TriageStartDate", "*") %> </td> The variable crit is passed in ViewData and is cast to...

Multiple Parameters with POST and MVC

Ok. So I have two elements on a page which are not located in a single form. I need these to be posted back to my controller via the JQuery.Ajax() method. Now the problem I have is that while my parameters do correctly post they only do so if I set them as strings and they include the parameter name in the value. So: Public ActionResult...

ASP.NET MVC: search in data entry form

Hello, and thanks for reading. I am building a data entry form. I am trying to figure out a way to let the user to provide a criteria (last name for instance), search the employee table for all employees that match the criteria, display the result in a way they can select the correct employee, and pass the the ID of that employee back t...