asp.net-mvc

Required Attribute for bool value type when used as checkbox

I'm running into a problem where I have a simple add/edit form and using client-side validation (jQuery/MicrosoftMvcJQueryValidation.js) which is generated from data annotations and enabled client side by calling the following in my view: <% Html.EnableClientValidation(); %> This seems to work fine for most elements, however I have an...

MVC1 project templates in VS 2010 beta?

Does anyone know if I can put the MVC 1 project templates in VS 2010 beta? If so, link? I have found a few links on the internets but they all link to a Codeplex project that doesn't have this particular project anymore. ...

Integrating Silverlight 'views' into an ASP.MVC application

We have developed a Silverlight Control which performs some biometric's to establish someone's identity and will be using it to authenicate a user in our MVC app. However we want to provide for someone which does not have Silverlight installed and therefore return a view which provides a normal login/password type stuff. My question i...

What to return from ASP.NET MVC action to allow jQuery ajax success event to fire?

Right now my ajax posts all fire their Error events even if the action did not cause an error. I have an ASP.NET MVC action that looks like: [AcceptVerbs(HttpVerbs.Post)] public virtual ActionResult StuffToDo(int id) { // do various things that work ... return new JsonResult(); // i have to return something, so this... } On...

How to pass local variable from Jquery function to ASP.NET MVC controller?

Hi I have a local variable called mode in JQuery function. Based on the radiobutton selection, this variable value is set in JQuery function. Now i want to access this value in COntroller? How can we do this. $(':radio').click(function() { var mode = this.value; }); Now How can I access this mode variable in my controller method. ...

ASP.NET MVC parser error

Hi, I have an asp.net mvc application on IIS 6.0 webserver. The problem is: i get a parser error. I tried with the default sample asp.net mvc project but i get the same error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error ...

Output Cache problem on ViewEngine that use 2 separate view for 1 controller

http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx To the sake of simplicity, please try out this. Basically, I am trying to do the mobile view engine, but then i found out that I have outputcache, which will cache one of 2 view (PC view) and then when i tried to access through mobile, it ...

Should I use PageAsyncTask or manual Threading within In ASP.NET MVC Controller for parallel operations

Hi everyone, I have an ASP.NET MVC application, and in one of the controllers I have two long-running operations. I want to execute them in parallel. At first, I simply rolled my own multithreading code by new'ing up a System.Threading.Thread() object, running it in the background, and thread.Join()ing it up before exiting the control...

ASP.NET WebForms and MVC Hybrid - Strange characters in URL (random stuff)

Hi, I am in the process of creating a hybrid webforms / mvc app. It all works find in VS with its debug web server. However, after overcoming numerous other issues and I am now stuck with a od problem indeed. When viewing pages served by controllers I am getting random characters show up in the URL - but the site still works, I think. F...

Can't find the 'open in browser' option when r-clicking on default.aspx

Something strange is going on for me. I can open the web application on my desktop computer just fine, where it opens the asp.net MVC application with a URL like http://localhost:5118/ when I rigth click on the default.aspx file and choose 'open in browser'. On my laptop, I don't have that option when I right click on default.aspx for ...

Accessing Server Tags inside Javascript in MVC project

I'd like to use some server tags inside a Javascript function: <%=Model.HtmlProperty%> In the past I have stored this value in a hidden input field, but when a property contains HTML you get problems with special characters such as quotes. I would like to avoid having to encode and decode in the controller to avoid problems with spec...

Mixing spark and webform view engines

Is it possible to use multiple view engines? I have a large(ish) site that is already using the webforms view engine, but we would like to move to spark for new features. Is this supported? any documentation online that details how to do this? ...

Flattening a complex json object for mvc binding

My controller is returning an object graph to the view in json format like this return Json(customer); On the view my json object looks like this { Name: 'Joe', Budget: { Amount: 500, Spend: 100 } } Which maps correctly to my customer object: public class Customer { public string Name {get;set;} public Budget Budg...

ASP.NET MVC Routes, redirect to controller depending on number of strings

I have a small site I am working on where I need to have 3 different routes such as: .com/id/foo 2 .com/id/foo/bar 3 .com/id/foo/bar/user So number 1 would be for the id of foo. Route 2 would be the id of bar. Finally route 3 would be the id of the user. How would I set the routes up to do this? ...

Jquery, Autocomplete using json, id's vs display values

I have kind of a complicated autocomplete issue. This is for a messaging system for a website I'm working on. I want it to work where you type in a user's name, it comes back with a thumb of their image and their name and their id. Then, when you select it, I want it to show the users name, but when it posts back I want it to send bac...

Using ActionLink and specifying the DELETE Constraint

I'm using RestfulRoutes written by Steve Hodgkiss. So far so good but I do have a question. I have a Session Controller that I want to use to destroy a users session when they click the logout button. How can I do this with and action link? So far I have the following. <%= Html.ActionLink("Logout", "Destroy", "Session") %> I need to ...

ASP.NET MVC ActionLink: Strange URL generated

Why does the following Html.ActionLink call: Html.ActionLink("Approve", "Advance", new { id = Model.ID, step = StepType.Approve }) generate a URL with query parameters rather than a "restful" URL, i.e.: http://localhost/Website/Case/Advance/1?step=Refer I only have the default route registered, do I need additional routes that can ...

Why does ASP.NET MVC care about my read only properties during databinding?

I have a read only property on my 'Address' model 'CityStateZip'. It's just a convenient way to get city, state, zip from a US address. It throws an exception if the country is not USA (the caller is supposed to check first). public string CityStateZip { get { if (IsUSA == false) { ...

ASP.NET MVC - RenderAction - PartialView - BeginForm() - multiple forms

So I have this ascx (partialView) control - ControlTemp I have an ajax.BeginForm inside ControlTemp like this: <% using (Ajax.BeginForm("ControlTemp", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divControlTemp" })) { .... <input type = "submit" /> <%}%> Inside my masterpage, I am using this part...

handle javascript injection in asp.net mvc

How can we handle the javascript injection in asp.net mvc (C#) application? I can use Html.Encode in my View. But the problem is i have html also to show in the page like a blog post. I need to remove the script entered in the input elements of the application? How can i do that in a common place? ...