When I'm adding a new strongly-typed view to an ASP.NET MVC project, I can select between different view content templates (Create Details, Edit, List). I have read these are templates based on the Visual Studio T4 code generation engine.
How can I author and configure my own templates and let them appear in the available templates when...
I have a integer stored in TempData, and it is getting periodically wiped for an unknown reason after 30-60 seconds of browsing around my site.
I have a break point on the place where the value is set and its never being set to null, yet somehow that value in TempData is getting nulled.
Any idea why this is happening?
...
It seems like most people are leaning towards creating single ModelViews for each view (Thunderdome Principle) in lieu of stuffing in weakly typed items into the ViewData dictionary.
So, with this in mind, for what tasks should the ViewDictionary be used for then? Really small one-off views? Don't use it at all?
...
I am going to be generating some hyperlinks on the fly driven from our database. So for example I go and get some information about a project, then based on the configuration information in that DB table (Which contains information like type of HTML fields to generate) I'll dynamically create Html controls from a custom control I create...
Does anyone know of a way to do something similar to Django's signals using LINQ to SQL?
I'm trying to record when new rows are inserted and when certain columns are updated, so I really just want pre_save and post_save signals.
I can kind of do it with some models by using the partials defined like OnFooIDChanging() and OnFooIDChanged...
Hi,
I tried to follow this but the default modelbinder let my array null on the server side.
HTML:
Question 1:
<input name="list[0]" type="radio" value="1000" />No
<input name="list[0]" type="radio" value="1001" />Yes
Question 2:
<input name="list[1]" type="radio" value="1002" />No
...
Controller action:
public ActionResult Anamne...
I'm unsure if this has been asked before but here goes.
I have an MVC application with the HTML looking like this;
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<EnvironmentalVandals.Controllers.MonthlyItemsFormViewModel>" %>
I have in the controller the following;
[...
I'm having a problem with model binding. If I do use the prefix in the CopyToModelStateDictionary method, I don't get the styling or validation messages for the invalid controls. If I don't use the prefix, I get the styling and validation messages, but the page crashes if the user hasn't made a selection from a dynamically created list o...
If I have a class that holds phone numbers, called PhoneNumbers and I have a MVC view with two text entry boxes, each mapped to a PhoneNumber and I want one to be optional and one to be required, how can I achieve this with NHibernate Validator?
Right now my PhoneNumber class looks like this:
public class PhoneNumber
{
[Pattern(@"^\d{...
What namespace has JObject in json.net?
Just installed int and can't seem to find that class?
...
Specifically, how can I pass the static method Request.IsAjaxRequest()?
I get the exception 'System.ArgumentNullException' when I try to test the following code:
if (Request.IsAjaxRequest())
{
return Json(data);
}
return View(data2);
I'm using Moq. Thanks for any help.
...
Hi Guys,
I am using unity & entlib for logging and caching in my Azure webapp - I have strange problem in that the web browser takes a very long time to load.
It seems there is a conflict with the web.config file but unsure what to do ? I need to wait 1-2 mins for the start page to display, sometimes it doesn't display at all - clean...
I have to build an xml output that represents a data structured for a flex chart placed in the view.
I have several options:
have the controller create the xml (using data from the DB), and return it to a view that actually does nothing, since everything is ready.
have the view strongly typed to the data model from the DB, and render t...
I'm returning multiple shapes to a page and am using a ViewData class that I've created. The namespace of this class is:
namespace IntranetMvcAreas.Areas.Accounts.Views.ContractsControl.ViewData
which I'm not sure it correct. In the page I attempted:
Inherits="System.Web.Mvc.ViewPage<ViewData.ContractsViewData>"
But ViewData does...
Hi,
is it possible to set a default .OnError handler for AjaxOptions in ActionLinks etc. ?
...
I'm trying to get to grips with the Validation messages in ASP.Net MVC. I have the following view
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Create User</h2>
<%= Html.Valida...
Hi,
I'm trying to post with JQuery like this:
$.post("NiceController/Create/", { field1: data1, field2: data2 },
function(data, textStatus) {
if (data.Status)
//Do something
}, "json");
The problem is, that when I'm not authenticated I don't get redirected, to log-on page, because it's not a full form submit. Question is:...
What are the possible reasons what Nullable<> types are disallowed to be passed as TModel parameter of System.Web.Mvc.ViewPage<TModel> generic? This could be handy sometimes.
In ASP.NET MVC source defined what TModel should be a class:
public class ViewPage<TModel> : ViewPage where TModel : class
but Nullable types are value types. M...
Hi,
is it possible to get a reference to the triggerElement that invoked the Ajax request in the onSuccess function?
<%=Ajax.ActionLink("x", a, r, New AjaxOptions With {.OnSuccess = _
"function(context) {alert('get triggerElement reference here?');}" })%>
...
Ok, this is for me a very tough challenge. We're taking our existing ASP.NET website and converting (redesigning the PL only) to MVC. Our site is very complex. But the hard part is to convert the existing custom controls to MVC equivilant. The custom controls (I am not talking about user controls) are just of course a class currently tha...