asp.net-mvc-2

How do you preserve the viewstate while using strongly typed views in asp MVC 2?

I have an ActionResult returning from a strongly typed view where I manually validate some conditions, pass in an error message, but would like to preserve the users responses. Since my View is strongly typed, I am calling it like this: return View("PrincipalInvestigatorForm", new SmartFormViewModel(sections, questions)); My problem ...

ajax.action link delete not able to display the updated records

<%= Ajax.ActionLink("Delete", "Delete", new { id = item.int_GroupId }, new AjaxOptions {HttpMethod="Delete", Confirm="Delete Group with Group ID:" + item.int_GroupId + " Group Name:" + item.vcr_GroupName})%>| [HttpDelete] public ActionResult Delete(int id, FormCollection collection) { try { Gro...

How to reference the DisplayTemplates defined in an Area from main project?

I defined a few display templates for classes and they work well when I put them in views/shared/DisplayTemplates. However after I move them into an area, looks like ASP.NET MVC won't look inside Area to find the templates. How to reference the DisplayTemplates defined in an Area from main project? Is that a good practise? ...

Can't figure out how to code my css

Hi, I'm a new poster in stackoverflow. The community seems really nice so I'll go ahead and post my question. I'm trying to style a asp.net MVC2 form so that instead of having all the fields on a strait line, I would like to have it like so: Label: Text field Label: Text field I know you could do that with a table but I would lik...

VS 2010 MVC Formatting

Hello, MVC is formatting my code horribly, and I was wondering if you can turn it off? I feel the answer is no, but I was hoping VS 2010 had built in a setting... Here's what its formatting as: <% if (org.UserKey.HasValue) { %> <%= org.Reference(i => i.UserReference).Email%> ...

ASP.NET MVC 2 - Setting id of Html.Form

Hey, How do you set the id of an Html.Form in ASP.NET MVC 2? I tried this: <% using (Html.BeginForm("Save", "Clients", new { id = "SubmitForm" })) {%> But it doesn't work, my form still doesn't have an id property: <form action="/TothSolutions/Secure/Clients/Save/SubmitForm" method="post"> I'm guessing this worked in ASP.NET MVC...

PortableArea and MasterPages

How can I design my portable areas such that the consumer can specify the MasterPage & various content placeholders & my portable area renders into those regions at run time? Any code samples and/or ideas? Thanks! ...

ASP.NET MVC DataAnnotations different table. Can it be done?

i have a language table which is as a foreign key in the link table , The link can be in 3 languages meaning there will be 3 rows in the link table every time i enter the record . i am using jQuery tabs to enter the records in 3 languages . OK so that thing is that there will be three text boxes for every field in the table.link name fie...

Working with images in asp.net MVC ViewMasterPage in design mode

While designing a master page i am adding a number of images to it. I have an image tag inside the master page, <img src="../../Content/Images/img19.jpg" class="profileImage" /> When i run my app, the image doesn't show up in the browser because the src path in the page that browser gets is same as in the master page. ie. "../../Co...

Custom HTML Helpers in ASP.NET MVC 2

Hi, I want to create a pagination helper. The only parameters that it needs are currentpage, pagecount and routename. However, I do not know if it is possible to use the return value of another html helper inside the definition of my html helper. I am referring specifically to Html.RouteLink. How can I go about doing something like this ...

asp.net mvc2 ajax.actionlink is not working refresh problem

has someone make ajax.actionlink for delete to work properly.After deleting the record successfully at the end it is not refreshing the page properly. the page refresh is my problem. i have defined the updatetarget id and returning view(model) from my controller but it is returning the master page with it. So the thing is that i am ha...

CSharpCodeProvider - Is it abusable?

Apologies for the shortness of the question, however I don't think it needs much elaboration. Any there any security implications caused by using the CSharpCodeProvider and could it open a server up for attack? ...

Mapping and metadata information could not be found for EntityType Exception

I am trying out ASP.NET MVC Framework 2 with the Microsoft Entity Framework and when I try and save new records I get this error: Mapping and metadata information could not be found for EntityType 'WebUI.Controllers.PersonViewModel' My Entity Framework container stores records of type Person and my view is strongly typed with class Pe...

How am I supposed to deploy an ASP.NET MVC 4.0 website?

What's the recommended way to deploy a website created with ASP.NET 4.0 and Visual Studio 2010? I've previously always added a web setup project to my solution, and used that to create an MSI, even for small applications. But when I build a web setup project in VS2010 it kind of works but some stuff still seems broken: 1. I need to tur...

How to set a default value with Html.TextBoxFor?

Simple question, if you use the Html Helper from ASP.NET MVC Framework 1 it is easy to set a default value on a textbox because there is an overload Html.TextBox(string name, object value). When I tried using the Html.TextBoxFor method, my first guess was to try the following which did not work: <%: Html.TextBoxFor(x => x.Age, new { va...

How do I display the duration it took to generate a page in a pages footer?

During debug builds I would like to show the duration it took, server side, to generate a page in the pages footer. So for example if a page takes 250ms server side I would like that displayed in the footer, in debug builds. How can I achieve this in an ASP.NET MVC project? ...

MVC map to nullable bool in model

With a view model containing the field: public bool? IsDefault { get; set; } I get an error when trying to map in the view: <%= Html.CheckBoxFor(model => model.IsDefault) %> Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?) I've tried casting, and using .Value and neither wor...

Silverlight 4, Google Chrome, and HttpWebRequest problem

My Silvrlight 4 application hosted in ASP.NET MVC 2 working fine when used through Internet Explorer 8, both in development server and remote web server (IIS 6.0). However when I try to browse through Google Chrome (version 5.0.375.70) it throws "remote server returned not found" error. The code causing the problem is the following: pub...

Starting with asp.net MVC

Hello, Actually im doing a home page that only have an action called Index() that returns the view Index.ascx. This index page will be composed by lastest news and lastest registered users, i think that create two partial views is the best idea (this way i could use it in other views). for other hand i have a data access class that c...

MVC Ajax.ActionLink doesn't find POST method

I have a POST method declared in my controller: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateComments(int id, string comments) { // ... } and an ActionLink in my view: <%= Ajax.ActionLink("update", "UpdateComments", new { id = Model.Id, comments = "test" }, new AjaxOpt...