I have a form posting to an action with MVC. I want to pull the selected drop down list item from the FormCollection in the action. How do I do it?
My Html form:
<% using (Html.BeginForm())
{%>
<select name="Content List">
<% foreach (String name in (ViewData["names"] as IQueryable<String>)) { %>
<option value="...
I have a simple model / view with things like Username, Password etc. and use helpers fine to hook it up.
I now have a field called "NumberOfChildren". I want to store a number in it (int) and I want it render a dropdown box containing "None", "1", "2" etc.
My thoughts would be that the model would have a list or a method that returns ...
I'm trying to validate a model containing other objects with validation rules using the System.ComponentModel.DataAnnotations attributes was hoping the default MVC implementation would suffice:
var obj = js.Deserialize(json, objectInfo.ObjectType);
if(!TryValidateModel(obj))
{
// Handle failed model validation.
}
The object is com...
Sorry for the length, but a picture is worth 1000 words:
In ASP.NET MVC 2, the input form field "name" attribute must contain exactly the syntax below that you would use to reference the object in C# in order to bind it back to the object upon post back. That said, if you have an object like the following where it contains multiple Ord...
If you have the following:
Asp.Net MVC 2 project having object classes that define view models.
Serialize these models to the web browser client using JSON.
Client adds information to the objects, like an Order Line on an Invoice.
Client sends back the object to the server for processing.
Is there any way to share with the client a d...
We're building a site that will have very minimal code, it's mostly just going to be a bunch of static pages served up. I know over time that will change and we'll want to swap in more dynamic information, so I've decided to go ahead and build a web application using ASP.NET MVC2 and the Spark view engine. There will be a couple of cont...
Hi, I have the code (snippet):
The Model is the IEnumerable object of the Person's class:
<% foreach (var item in Model)
{ %>
<tr>
<td><%= Html.DisplayFor(x=>item.Name) %></td>
</tr>
<% } %>
it renders only labels like that:
<td>Tommy</td>
According to the link it should be rendering a HTML markup somethi...
Hi -- I am trying to set up input validation using regular expressions, but I keep getting this error when I enter "<test>" in a textbox:
A potentially dangerous Request.Form value was detected from the client
I have this in the web.config:
<system.web>
<httpRuntime requestValidationMode="2.0" />
I also have this in the web.con...
Hi, I'm wondering about one thing - let's assume that the user clicks a button, and the asynch controller's action is invoked. What happens, when the asynchronous action takes e.g. 10 seconds? The user has to wait 10 seconds to view the result of the action? If so, are the asynch controllers really helpful ?
...
The following are true:
One of my columns (BirthDate) is of type Date in SQL Server.
This very same column (BirthDate) is of type DateTime when EF generates the model.
I am using JQuery UI Datepicker on the client side to be able to select the BirthDate.
I have the following validation logic in my buddy class:
[Required(ErrorMessage...
Hey,
Has anyone been able to get the Areas in ASP.NET MVC 2 to work?
I created a new Area called "Secure" and placed a new controller in it named HomeController. I then Created a new Home/Index.aspx view. However, when I browse to http://localhost/myapp/Secure/ it gives a 404 resource cannot be found. http://localhost/myapp/Secure/Hom...
Is there any way to define a global template for the Html.EditorFor helper?
I would like to alter the markup that is output so that for example instead of rendering
<div class="editor-label">
<label .../>
</div>
<div class="editor-field">
<input .../>
</div>
It would render:
<div>
<div class="label"><label..../></div>
<d...
Why can't I set ShowForEdit model metadata with an attribute?
It seems that the only attribute provided to alter this is [ScaffoldColumn], which sets both ShowForEdit and ShowForDisplay, which is not what I want to do. I want to be able to annotate the two separately from on my model.
...
This question is based on using the Asp.Net MVC tabular layout display template from Phil Haack http://haacked.com/archive/2010/05/05/asp-net-mvc-tabular-display-template.aspx
The problem is in the Html.DisplayFor(m => propertyMetadata.Model). This displays the data from the property just fine, however it doesn't use any of the data ann...
Hi, I have the next controller:
public ViewResult AddPresentation(string categoryKey)
{
Category category = new Category();
category = repository.GetCategoryByKey(categoryKey);
return View(category);
}
In the "AddPresentationView" I have to fill some object properties with values from the "AddPresentat...
Hello,
i am workin on asp.net mvc in that i using partial views. i got one proble ie date picker is working properly on IE but it is not working on Mozilla Firefox. the i have used is:
<link href="<%=ResolveClientUrl("~/Scripts/Themes/ui-lightness/jquery-ui-1.7.2.custom.css")%>" rel="stylesheet" type="text/css" />
<script src="../...
I have a Asp.Net Web Site deployed as a WebSite inside IIS 7.5.
http://localhost/WebSite
Then I have a second Asp.Net MVC 2 web application which is deployed as Sub Application inside the above WebSite. So the mvc aplication should work on the following Url.
http://localhost/WebSite/MvcApp/
The web site works fine but when ...
Using ASP.NET MVC 2 and and Html.RenderAction in my masterpage implemented as below throws an error with "the controller for path '/' was not found":
I'm a bit of a newbie, do i have to do something in RegisterRoutes to make this work?
<% Html.RenderAction("TeaserList", "SportEventController"); %>
public class SportEventController : C...
Hi guys.
Can you help me how to create my own ViewData.Model from mesto?
public ActionResult Index()
{
ViewData["Message"] = "Moji Priatelia";
var friends = from friend in friendsDb.FriendsTables
orderby friend.Priezvisko
select friend;
var mesto =...
This code is a no-go
var errors = (from error in db.ELMAH_Error
select new
{
error.Application,
error.Host,
error.Type,
error.Source,
error.Message,
error.User,
error.StatusCode,
error.TimeUtc
}).ToList();
...