asp.net-mvc-2

In ASP.NET MVC 2 - How do I get Route Values into my navigation controller so I can highlight the current link?

I'm trying to get the current Route into my navigation controller so I can run comparisons as the navigation menu data is populated. My Links object is like this: public class StreamNavLinks { public string Text { get; set; } public RouteValueDictionary RouteValues { get; set; } public bool IsSelected { get; set; } } In t...

alternative of Listbox in html

hello everyone, i have a transliteration application developed in c#.net 3.5. the user interface of application looks something like after each word is typed i m showing list of probable Urdu words in Listbox next to caret position from where user can select the desired word. now i want to convert it to web application. my question i...

Querystring Route in MVC2

I'm trying to create a route to a specific controller/action which needs to accept optional querystring parameters. the urls i'd like to accept are: /Products/ProductsListJson /Products/ProductsListJson?productTypeId=1 /Products/ProductsListJson?productTypeId=1&brandId=2 /Products/ProductsListJson?productTypeId=1&brandId=2&year=2010 ...

How do I specify a strongly-typed html helper that uses a nested class of the model instead of the model itself?

I am creating a strongly-typed search form in ASP.NET MVC 2 that posts to a results page via FormMethod.Get (i.e. the form inputs and their values are posted to the search results query string). How do I specify strongly-typed html helpers that use a nested class of the model instead of the model itself so that I don't get the dot notati...

Pattern for creating resuable controls in asp.net MVC

I would like to create simple controls that can be Easily reused across applications. Is there a current set of best practices or patterns for creating such controls. Examples of such controls could be Paging, List or Grid display, etc... I'm not looking to make controls with tons of options just really simple controls that I can add t...

ASP.NET MVC - Unit testing, mocking HttpContext without using any mock framework

Since I'm having problem with unit testing RenderPartialViewToString() with Moq framework (http://stackoverflow.com/questions/3621961/asp-net-mvc-unit-testing-renderpartialviewtostring-with-moq-framework), I'm thinking about getting my controller directly, without using Moq for these particular test, however, how do I mocks (or set) the ...

IIS 6.0 Testing Environment in Windows 7

Trying to develop and test an ASP.NET MVC 2 as well as a hosted WCF app where the client is limited to IIS 6.0 (OS Windows 2003). I am developing and testing in Windows 7 which has IIS 7. I do not have access to a Windows 2003 disk, so creating a VM doesn't appear to be a viable option for me... Any suggestions or tips would be greatly...

Linq query Group By error in ASP.NET MVC 2

Hello All, I am having a bit of a struggle using linq and returning a list while trying to group. In my view, I have the following: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcApplication1.Models.Log>>" %> <table> <tr> <th> ...

C# Listing/Checking Object Variables?

With an ASP.NET MVC project I'm working on, I am required to check whether bit variables within a LINQ-To-SQL class are true. So far, After checking whether or not each variable is true or false, I then push the value of the field into a List and return it like so: public List<String> GetVarList() { List<String> list = new List<Str...

Create User by profession - How to Populate/Submit/Validate form?

Hi geeks, I am trying to create user by registration form which contains dropdown for profession in ASP.NET MVC Eg. Individual, professional, manager etc. some fields are common like name & Last Name... some fields are unique by profession... how do i program it with ajax. Thanks ...

How can I override a .svc file in my routing table?

I have this URL that was used from some JSON post back from the main website: http://site/Services/api.svc/UpdateItem We are in the process of updating the web site slowly to ASP.Net MVC 2 and don't want to break any current URL's in the system. (JavaScript refresh issues) I have deleted the /Services/api.svc and have moved the logic...

ASP.MVC 2.0 How display Blank textbox for Model property of Integer when integer value is zero

I have the following code: <div class="editor-field"> <%: Html.TextBoxFor(model => model.MyId) %> <%: Html.ValidationMessageFor(model => model.MyId) %> </div> The 'MyId' property of the model is of type integer. When the form is in 'Create' mode, MyId value is 0. How can I, prevent 0 displaying and rather render the textbox with an...

In ASP MVC, how can I return a new view AND a file to the user?

Thought I would pose this to the StackOverflow crowd since I've run out of ideas. I have a request from users that once a button is clicked, a PDF form is generated which they would like to automatically view, and once they close the PDF the page will already be a "Final page", not the page they clicked the button from. In my pre-final...

MVC status page response

If some specific request coming to MVC web site, e.g status.aspx how i may dynamically create a response e.g "Server1 OK" without creating any additional controllers to process this request. We have web farm and each of the sites should response " OK" when status.aspx requested. Or i should create for example controller Status and redi...

Change default Visual Studio behavior for MVC 2 project

I've created an MVC 2 project with nested areas, such as: Areas -->A -->C --> Controllers --> Models --> Views -->D --> Controllers --> Models --> Views -->Controllers -->Models -->Views -->B -->E --> Controllers --> Models --> Views -->F --> Controllers ...

Prevent MVC Action method from executing if a parameter is null

I've thought of a few ways of doing this but I want to get the community's view. I have a feeling that the answer is cringeworthily simple - I'm not afraid to look stupid (my kids took that fear away from me long ago!) I'm writing an XML REST web service using MVC2. All XML Types that consumers of the web service will receive and send...

how to show error messages in asp.net MVC2.0

Hi, while coding in asp.net C# MVC 2.0, how to show error messages let say there is try {}..Catch{} or If Else ... then if i want to show error messages , then how can i code? ...

OneWay Databinding for ViewModel

Hi guys, I have some fields in my ViewModel that I only need for the output in my View. But they are always getting send when submitting the form. That's not only annoying, but also dangerous, because I definitly don't want that databinding for these viewmodel fields. Are there any change to define a OneWay Databinding for some of my v...

In Settings.settings, default Provider does not support user-specific settings?

I have this project in VS2010, MVC2 written in C#. My problem is that it doesn't seem like I can have user-specific settings, only application-specific, which I then can't update from code which is sort of useless to me at the moment.. Any ideas on this? I mean, I don't get any errors or anything like that. In the Settings-dialog I can ...

ASP.NET Data Caching? Memcache equivalent

Having used PHP on Linux a lot, I'm used to using memcache so that the database doesnt have to be accessed on every single request. What do people use on Windows the achieve this? From the asp.net mvc applications which I've seen, none of them use any sort of cache, they just hit the database on every request? Is this common, and if so, ...