Hi there,
I'm using ASP.NET MVC 2 and want to figure out how to re-trigger the validation on my model after it has been populated using a custom binder.
So, I start with a couple of EF classes which are associated, Booking and Traveller (each booking can have one or more travellers)
Here's the buddy class I'm using to place balidation...
Hello
Lets say I have something like this:
public ActionResult Test(SomeModel m)
{
try
{
_db.SaveModel(m);
SendMailToUser(m);
RedirectToRoute("Something");
}
catch
{
return View();
}
}
And I got problems with howto deal with this if "SendMailToUser" fails. Model gets saved to...
I like the way model binding in django works: you send stuff that you need in a Json-like way:
'param1': val,
'param2': val
In ASP.NET MVC you can't do it primarily because C# is a static language. You can use ViewData but it's ugly and not recommended.
So I had to create dozens of ViewModels for every view: IndexViewModel, AboutView...
if I decorate the properties of my ViewModels with attributes like this:
public class Vm
{
[Required]
[StringLength(35)]
public string Name {get;set;}
}
I am going to get english validation messages:
"this field is required"
"The field Name must be a string with a maximum length of 35"
how could I translate them ?
...
Using Entity Framework with MVC2, I have a series of date textboxes, that I want to display data from the model in a short date format, but I have to use Html.TextBoxFor in order for the update code to work (Having tried using HTML.Textbox the data never gets saved to the model).
<%: Html.TextBoxFor(model => model.Item.Date, String.For...
Hi guys,
I have an MVC webapp that I'm putting together now. A second app publishes data to a database which my webapp reads from.
I am using SharedCache as a cache provider for my NHibernate and I wish to assign "expirations" to my entities (so I can guarentee a level of freshness of the data) - and knowing that some entities are rare...
The current code of one of the views in my project is a large, monolithic one and I just want to organize it. Is it just fine to place methods inside my ASP.NET MVC view?
...
Hi I have add the provider in my web config as below:
<add name="MvcSiteMapProvider"
type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
siteMapFile="~/Sitemap/SiteMap.sitemap"
securityTrimmingEnabled="true"
enableLocalization="true"
scanAssembliesForSit...
I have a page that contains multiple div's. Action on one div changes the content of other div.
Each div loads a partial view from controller. For example- a div for "Search" and another div for "SearchResult".
"Search" div contains couple of fields and a button. On click of this button a controller method is invoked asynchronously usi...
I use a foreach loop inside ASP.NET MVC View page. For each element of the collection that foreach operates on I create two rows - one for display, one for edit. I want to hide the edit row and only display it later depending on user action.
If I hide the edit rows with display: none, then jQuery's show() method cannot redisplay it agai...
Is there any way to do this? I thought I'd find hundreds of results on google for this but not really finding anything. I want to set it to a location either on the web server or on a mapped networked drive somewhere.
I'm talking about with <input type="file" ... /> to clarify.
...
Hi guys,
Is there any way to show custom input validation message through javascript? I have javascript validation method innvoked with Form.Submit, so if validation goes wrong, I'd like to have a custom text next to the field I have validated (similar as ASP.NET MVC 2 validation summary).
Regards
...
Is there any pagination helper like stackoverflow in asp.net mvc?
...
I have HelpBoxes in my DB. those are messages people get on the site. each message has a receiver. either it's an organisation or a user, or both.
I have this Enum
public enum Ontvangers {
All = 'A',
Organisation = 'I',
User = 'D'
}
now in my index view
public ActionResult Index(string schooljaarp...
Hello,
I am using Form Authentication in an ASP.NET MVC project.
When the current user click on the Exit link the code execute an action that does in sequence:
System.Web.Security.FormsAuthentication.SignOut();
Session.Abandon();
The second call is not properly needed because I am not using session at all.
The problem is that if I...
// html
<% using (Html.BeginForm("MyAction", "MyController",
new { id = ViewContext.RouteData.Values["id"] },
FormMethod.Post,
new { enctype = "multipart/form-data", class="myForm" }))
{ %>
<input type="file" name="blah" />
<% } %>
// script
$container.find('.myButton')....
this is my renderparial
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<a href='<%= Url.Action("Edit", new {id=Model.ID}) %>'>
<img src="<%= Url.Content("~/img/pencil.png") %>" alt="Edit" width="16" /></a>
I basically want to call it in this way:
<% Html.RenderPartial("edit", new...
Hi, I need to create a list of dynamically generated entries on the client as the user can control how many entries he needs pressing a + symbol. Functionality in some sense is similar to the "Google Finance Stock Screener" add criteria.
In code I have a model that looks like this:
public class Model
{
public List<string> DynamicLi...
I have an Ajax Form that looks like this:
<% using (Ajax.BeginForm("Update", new AjaxOptions
{ UpdateTargetId = "message", InsertionMode = InsertionMode.Replace,
OnSuccess = "success", OnFailure = "error" })) { %>
I can get "error" to run on a failure but i would like to alert the error message. How can i get this information...
Short but simple?
I have an edit.ascx is in the shared folder. I call it like this:
<% Html.RenderPartial("edit", item.hlpb_ID); %>
If I put it in a subfolder, it cant find the file, how to fix that?
...