asp.net-mvc-2

Inconsistent property name casing in generated JsonResult

时光怂恿深爱的人放手 提交于 2019-12-12 16:17:49
问题 I've been scratching my head on this for a while now and have decided to let the SO community take a crack at it... I have a few actions that respond to POSTs from the client side that do simple tasks and return a JsonResult built from an anonymous class with a simple Boolean "Success" property if it succeeds, or returns a PartialViewResult with ModelState errors if the action was unsuccessful: <HttpPost()> _ Public Function UpdateHeader(ByVal header As XmlReturnHeader) As ActionResult If

Need help using the DefaultModelBinder for a nested model

…衆ロ難τιáo~ 提交于 2019-12-12 16:15:39
问题 There are a few related questions, but I can't find an answer that works. Assuming I have the following models: public class EditorViewModel { public Account Account {get;set;} public string SomeSimpleStuff {get;set;} } public class Account { public string AccountName {get;set;} public int MorePrimitivesFollow {get;set;} } and a view that extends ViewPage<EditorViewModel> which does the following: <%= Html.TextBoxFor(model => model.Account.AccountName)%> <%= Html.ValidationMessageFor(model =>

ModelMetaData: How to get “Parent”-Metadata?

南笙酒味 提交于 2019-12-12 13:33:30
问题 In my view I call Html.EditFor() which triggers a custom editor-template for this datatype. Additionally I pass some Metadata with it (and that's the part I don't like): <% ModelMetadata metaTitle = ModelMetadataProviders.Current.GetMetadataForProperty(null, Model.GetType(), "Title"); %> <%: Html.EditorFor(x => Model.Title, new { metaData = metaTitle })%> The passed type (property Title) is of type 'Translation'. Within the custom editor-template I have to read the passed metadata from the

How to reference javascript file in ASP.NET MVC 2 Views folder?

Deadly 提交于 2019-12-12 13:15:36
问题 I am trying to accomodate a corporate standard where all page-level javascript is contained in an external file and not included within the ASPX or ASCX file. Using ASP.NET MVC 2, I'm wondering how I can reference the script file (.js) relative to the view. In other words, I don't want to polute my Scripts folder with all of the small .js files that will exist in the application. From an organizational perspective, having the .js file alongside the .aspx/.ascx file makes the most sense. For

How do I use XSLT in .NET?

情到浓时终转凉″ 提交于 2019-12-12 11:15:40
问题 I am going to be translating an XML document into another XML document based on an eXtensible Style Language Transformation. Where can I find good tutorials about how to do this in .NET? I have found some stuff about how to do it using open source tools. But what about the .NET framework? Just a couple of other quick questions... Could somebody please give me a quick and dirty explanation of the XSLT order of operations? I am still a little confused about what happens? Are there any explicit

Session not sticking for ASP.NET MVC2 in IIS7.5 in IE8

会有一股神秘感。 提交于 2019-12-12 11:10:42
问题 We have an ASP.NET MVC2 web application. For reasons outside the scope of this issue we decided to use the classic session state in the application. Following features are implemented in it related to session. Session_Start event handler in global.asax stores a variable in session. This is in relation to a workaround to detect session expiration. Session being used has the following values in web.config: sessionState timeout="30" mode="InProc" cookieless="UseCookies" Forms authentication is

How to construct HttpPostedFileBase?

我与影子孤独终老i 提交于 2019-12-12 10:55:49
问题 I have to write a Unit test for this method but I am unable to construct HttpPostedFileBase... When I run the method from the browser, it works well but I really need an autoamted unit test for that. So my question is: how do I construct HttpPosterFileBase in order to pass a file to HttpPostedFileBase. Thanks. public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> files) { foreach (var file in files) { // ... } } 回答1: How about doing something like this: public class

Adding custom attributes to the SiteMap of ASP.NET MVC

南楼画角 提交于 2019-12-12 10:48:21
问题 I am using built in asp.net sitemap in asp.net mvc with the following schema http://schemas.microsoft.com/AspNet/SiteMap-File-1.0 I have the following attributes, resourcekey, title & description. I would like to add few more attributes to the sitemapNode, kindly let me know if it is possible to add new attribute in sitemap file and then read it via the sitemap class. 回答1: The SiteMap schema supports custom attributes and they can be accessed via the indexer property of the SiteMapNode class.

Entity Framework error when submitting empty fields

社会主义新天地 提交于 2019-12-12 10:44:56
问题 VS 2010 Beta 2, .NET 4. In my ASP.NET MVC 2 application, when I submit a form to an action method that accepts an object created by the entity framework, I get the following error: Exception Details: System.Data.ConstraintException: This property cannot be set to a null value. Source Error: Line 4500: OnTextChanging(value); Line 4501: ReportPropertyChanging("Text"); Line 4502: _Text = StructuralObject.SetValidValue(value, false); Line 4503: ReportPropertyChanged("Text"); Line 4504:

ASP.NET MVC 2 and sparkviewengine rendering single quotes to double quotes in html5 data- attribute

坚强是说给别人听的谎言 提交于 2019-12-12 10:22:54
问题 I'm having a problem with adding a json value as a data-attribute in a html5 page. We use the spark view engine (v1.5) in our asp.net mvc 2.0 website. The following viewcode: <a href='${Url.Action("edit", new { id = vehicle.VehicleId })}' title='Bewerken' class='dialog dialog-edit' data-dialogoptions='{"beforeOpen":"initAlarmZoneForm"}'><span class="silk-icon silk-icon-page-edit"></span></a> is being rendered as: <a href="/Alarm/AlarmZone/edit/4" title="Bewerken" class="dialog dialog-edit"