razor

ASP.Net MVC 3 RC2, Partial Views Form Handling

痞子三分冷 提交于 2019-12-21 23:10:09
问题 After years of Web Forms development I've decided to give MVC a go. I've been able to work through most of the other stumbling blocks, but I'm kind of stuck on this one. In Web Forms I would create controls for each of my forms in order to modularize so I could re-use them throughout my sites. I am attempting to do the same thing in MVC but with partial views and am not having much luck. It's probably something simple, and maybe I'm just not searching on the right set of keywords to find the

is it posible do have Html.ActionLink inside a DropDownList Without java script?

谁说胖子不能爱 提交于 2019-12-21 21:51:09
问题 Is it possible to have something like this? @Html.DropDownListFor( @Html.ActionLink("About", "About", "Home") @Html.ActionLink("mypage","index","Home") @Html.ActionLink("apage","anypage","Home") @Html.ActionLink("Test","Test","home") @Html.ActionLink("pagetest", "tsetPage", "Home") ); 回答1: No, this is not possible without javascript. Especially if you want the page to navigate to the corresponding address once the user selects an item in this dropdown. If you don't want to use javascript you

How to pass strong-typed model as data param to jquery ajax post?

筅森魡賤 提交于 2019-12-21 21:35:23
问题 Is there an easy way to pass my strong-typed view model as the data parameter to this jquery ajax call? Every example I've seen, I'd have to build the json myself e.g. { Property : "Value", etc. }. Isn't there some luscious js helpers/codz teh do this? $.ajax({ url: '/mycontroller/myaction', type: 'POST', data: <== Here contentType: 'application/json; charset=utf-8', success: function (data.success) { alert(data); }, error: function () { alert("error"); } }); 回答1: You could write a helper

How to Combine two models into a single model and pass it to view using asp.net MVC razor

最后都变了- 提交于 2019-12-21 21:32:58
问题 I'm trying to combine two models (tblCategories and tblProducts) into a single model and pass it to a view. But was not able to. tblCategory.cs which is main model has the following data namespace ScaffoldCreate.Models { using System; using System.Collections.Generic; public partial class tblCategory { public int CategoryId { get; set; } public string Name { get; set; } } } tblProduct.cs public partial class tblProduct { public int ProductId { get; set; } public int ProductName { get; set; }

ASP.NET MVC Strongly-Type ViewModel - Combine Create/List Views

℡╲_俬逩灬. 提交于 2019-12-21 21:15:31
问题 I am learning ASP.NET MVC and Entity Framework Code First, LINQ by creating a simple Bug/Feature tracking system. I would like to mimic the Twitter interface by having the user submit a form above and having the submitted content appear below. I am not sure how to structure the strongly-typed view and the said model. I would like to merge my Create and Index views into a single view, the problem is the Create takes a single type Entry ( Pylon.Models.Entry ), while the Index takes IEnumerable

Handling session timeout in ajax

…衆ロ難τιáo~ 提交于 2019-12-21 21:09:14
问题 In my MVC app I have the following attribute that checks for logged on users: public override void OnActionExecuting(ActionExecutingContext filterContext) { .... if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) { filterContext.Result = new Http403Result(); filterContext.HttpContext.Response.StatusCode = 403; } ... } Layout.cshtml $("body").ajaxError( function (e, request, settings, exception) { alert('in'); if (request.status == 403) { window.location = '@Url.Action(

Handling session timeout in ajax

别来无恙 提交于 2019-12-21 21:05:09
问题 In my MVC app I have the following attribute that checks for logged on users: public override void OnActionExecuting(ActionExecutingContext filterContext) { .... if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) { filterContext.Result = new Http403Result(); filterContext.HttpContext.Response.StatusCode = 403; } ... } Layout.cshtml $("body").ajaxError( function (e, request, settings, exception) { alert('in'); if (request.status == 403) { window.location = '@Url.Action(

How to Create Session Variable in JavaScript MVC3 Razor View engine .cshtml

久未见 提交于 2019-12-21 20:53:22
问题 I am using MVC3 with Razor View engine, i have .cshtml page in that i have a JavaScript function, inside that JavaScript function, i want to create Session variable and retrieve that session in same JavaScript function. how to achieve this.. 回答1: Description The Session is on the server side so you need to call the server in order to set or retrieve session variables. Just post to a controller and set the Session variable there. Sample jQuery $(function () { $.post('/SetSession/SetVariable',

Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, or one of its dependencies

我们两清 提交于 2019-12-21 20:51:47
问题 Please somebody help me fix this issue. Umbraco application as parent on IIS6 has the following version of System.Web.WebPages.Razor. <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,

ASP.NET MVC 4 Bundling - Individual File URLs in DEBUG mode

夙愿已清 提交于 2019-12-21 20:38:53
问题 Problem: In the HTML5 offline app being done in ASP.NET MVC 4.5, we are bundling and minifying the styles and scripts using the framework's built-in feature. Everything working well with the pages themselves, but for writing into the Cache Manifest, where (because of the we we are writing it) it is always only emitting the bundled URL. And so, we are not able to debug JavaScript in the offline mode, as the individual debug js files are not getting into the application cache. Code: