asp.net-mvc-2

.net mvc4 view / c# anonymous type and object htmlAttributes: new {class="mycssclass"} error

Ok, I cant find the answer to this: <%: Html.ActionLink("Click Here", "Action", null, new {class="myClass"})%> I want to set the CSS class attribute of the generated element. Obviously, C# will not allow me to use "class" as the name of an object's member. What should I do? ...

problem with select list and dictionary in asp.net mvc 2

Hi, I am using asp.net mvc 2 + c#. Scenario is : I have create view for user. I am manually (dynamically) taking 3 drop downs with assign as dictionaries to them. but problem is that always I need to pass "Key" as as data field.so while runtime it generates 3 values as (1,1,1) in collection("Key"). how should i differentiate this which ...

How to know the colmn on which filtering is applied on telerik grid in MVC

Hi I have an MVC application and in that i am using telerik grid to display the list . I am also using filtering option on the column. Is is possible to know on which column the current filtering is applied i.e to get the column name and value or if possible to highlight thoes column. Thanks supriya ...

SaveChanges() to update is not working

Hi, I am using MVC 2 and EF 4. I am trying to update my Application entity using my own stored procedure, but it is not updating. I checked out SQL Profiler and it is not even reaching the database. I also use an insert stored procedure and it works fine. Both stored procedures (insert and update) are mapped correctly. Does anyone ...

2 tables 1 view ASP MVC

Hi, I need some help. What I am trying to do is show the locations of a device belonging to a specific project. On the projects page I have a button which goes to the google map. For projects I have a Projects model and controller. Ive got 2 tables, a table containing the location of a device and a project table. I want to display all...

How to convert byte array into it's appropriate file format in ASP.NET MVC

I have a system that's supposed to convert a byte array (not knowing whether its pdf, txt, or doc) provided to me into a downloadable file. Now usually in ASP.NET MVC I would do it like this. return File(labTestResult.File, "application/pdf"); That's easy because I know what the filetype is. Now that the filetype could be anything, is...

How to Implement "if active" detection in an Html.Helper?

Apologies, I'm new to ASP.NET MVC. :) I'm unsure if this is simple a misunderstanding, or incorrect paradigm to use for this kind of functionality, but this is what I've come up with so far... I wish to provide the common functionality adding a css attribute (in this case "active") to an anchor tag, when we detect that the user is on t...

Download link in asp.net mvc

Hi, I have uploaded the document from my asp.net mvc 2 application to application domain. there is a directory name as "Docs". I want to create the link for download the document from my application . how to do that? Edited: I am taking this link from database. as "item.DownloadPath". I want to check that i this value is null or not ....

Programatically get controller address of ASP.NET MVC application

Say I want to send an email from my MVC application containing a link back to an item. So I want something in my controller like: string link = "www.mysite/mycontroller/itemdetails/23"; can I retrieve this programatically so it works on whatever server/configuration i happen stick it on? eg string link = GetCurrentActionRoute() + ...

ASP MVC variable to javascript?

I am trying to get the locations of devices per project. I have a page which shows a google map and a list of all devices that belong to a project. My actions are: public ActionResult GoogleMaps(int id) { return View(Project.Find(id).DeviceLocations); } public ActionResult Map(int id) { var map = Project.Find(id).D...

Silverlight application with binary xml

My silverlight + ASP.NET MVC application does the following: 1) Silverlight client sends request via HttpWebRequest. 2) ASP.NET MVC connects to a SQL Server database (stored procedure) and gets back XML data It then sends that raw xml to the client (no web services or WCF). 3) Silverlight client receives xml and deserializes it wit...

asp.net mvc2 Routes

Hi, So I have added this route to my map: routes.MapRoute( "Default", "/Bikes/{id}", new { controller = "Bike", action = "Detail" } ); But for SEO reasons we need to have urls like: /bikes/54/name-of-bike/kind-of-bike/number-of-wheels ... etc etc. But everything after id (54) can be ignored. Does a...

How do I pass multiple models to partial views in ASP.NET MVC

I've been reading Scott Guthrie's post on Passing ViewData from Controllers to Views, but I don't think the lesson is clicking for my specific situation. (Note: Due to client proprietary restrictions, I can't talk paste the actual code, so I apologize if my made up case is a bit stupid/confusing.) I have a Controller called ScenarioCon...

DataType vs UiHint

I have been using mvc2 for a while now, and when i need to set the template i use the DataType Attribute [DataType("DropDown")] public int Field { get; set; } I see others using UiHint to achieve the same results [UiHint("DropDown")] public int Field { get; set; } What is the difference between using these two a...

ASP.NET MVC2 -- Trouble with Model Binding and Html.Textbox()

ASP.NET MVC Model Binding is still new to me and I'm trying to understand exactly how it works. Right now, I appear to be having problems with a feature of Html.Textbox() Specifically, I have a View where I set Html.Textbox to a value both in the "Get" and the "Post". It sets fine in the "Get", but after the user submits a value during ...

Programatically disabling jQuery client validation in ASP.NET MVC

I am using the jQuery MVC validation library for ASP.NET MVC, which is working fine. However, on my form I have a 'Cancel' and a 'Save' button, both of which I want to submit the form back to the server. However, if the user clicks 'Cancel' I need to disable the client side validation so that the user doesn't get prompted to complete...

ASP.NET MVC 2. Cannot create an instance of an interface.

I use ASP.NET MVC 2 for my project. I'm trying to edit my product information using next code: [HttpGet] public ActionResult Edit(int id) { IProduct product = productService.getProductById(id); return View(product); } IProduct and other IEntities are instansing using IoC Castle Windsor. Page for Edit i...

How do I pass a custom class and a seperate array to a view in ASP.NET MVC?

Hi, I want to pass a custom class to a View, along with an array derived from some of that class's values. I can pass the array without problems, but I've got no idea on how to pass the class as a whole - I'm new to OO programming, never mind MVC. I've created a ViewModel which looks like this: (put together after reading the Nerddinner...

Naming conventions for ASP.NET MVC routes

From Rails and some people's ASP.NET MVC examples I got the feeling that routes are mostly written in lowercase. C# conventions do require uppercase classes and method names so controllers and controller action's will remain uppercase but I'm wondering if I should start writing routes in global.asax.cs in all lowercase (as opposed to wha...

Web service call limitations when using async controllers in MVC2?

I am running a MVC2 application (.net 4.0 on IIS7) and when a form is submitted I have to send invoke two external web services, wait for the responses, do something with it, and return a response. The problem is that the web services take about 20 seconds each to reply (this is beyond my control). I decided to move to async controllers ...