html-helper

How to do Model Binding with Jquery Ajax

送分小仙女□ 提交于 2020-01-13 03:15:33
问题 I'd like to use model binding to keep my controllers looking cleaner, you can see how much nicer it is using model binding: public ActionResult Create(Person personToCreate) { //Create person here } vs public ActionResult Create(string firstName, string lastName, string address, string phoneNum, string email, string postalCode, string city, string province, string country) { //Create person here } When doing model binding, we can just use a form with the correct names in the Html.TextBox("")

ASP.NET MVC Html Helper

大城市里の小女人 提交于 2020-01-12 09:58:29
问题 I try to create some Html Helpers which will have an opening tag and closing tag which will include other contents like the Html.BeginForm does. For example in Razor we can use the Html.BeginForm helper which has the following syntax: @using (Html.BeginForm()) { } This code will include the contents of curly brackets within a and . The only way that I solved opening and closing a tag with contents is by using two html helpers. I define two html helpers: public static MvcHtmlString StartForm

ASP.NET MVC 3 - Ajax.BeginForm vs jQuery Form Plugin

删除回忆录丶 提交于 2020-01-12 06:38:10
问题 I'm starting a new ASP.NET MVC 3 project and am going to implement some screens that are read only by default but allow the user to edit information by clicking on an Edit button. I want these screens to be AJAXed. I have previously used the jQuery Form Plugin to implement similar screens on an ASP.NET MVC 2 project. I've just discovered the existence of Ajax.BeginForm() and was wondering whether I should use that since it is built in, instead of using the jQuery Form Plugin. I've done a

ASP.NET MVC Beta 1 - where is Html.RenderPartial?

╄→гoц情女王★ 提交于 2020-01-10 23:20:43
问题 I'm just in the process of upgrading my Preview 5 application to Beta 1, and I'm nearly there save for this one error when trying to render a control: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?) My markup (in the .aspx View Content Page) is: <% Html.RenderPartial("Controls/UserForm"

Strange behaviour with MVC posting list

痞子三分冷 提交于 2020-01-06 08:28:06
问题 I have the following dynamically created textboxes in my view: @for (int i = 0; i < Model.MullionList.Count; i++) { ItemDrops curMullItem = Model.MullionList.ElementAt(i); <div class="form-group"> @Html.Label(curMullItem.ItemName.ToString(), new { @class = "col-sm-6 control-label" }) <div class="col-sm-6"> @Html.TextBoxFor(x => x.MullionList[i].ItemPossInfo, new { @class = "form-control" }) @Html.HiddenFor(x => x.MullionList[i].ItemName) </div> </div> } I noticed occaionally for certain types

Concatenate a string for DisplayFor

拜拜、爱过 提交于 2020-01-06 07:00:31
问题 I have a model called Lines. On it I have a address class that contains a number of strings, i.e.: public string ReferenceKey { get; set; } public string Country { get; set; } public string County { get; set; } public string Postcode { get; set; } public string PremisesName { get; set; } public string PremisesName { get; set; } I get information back from a webservice call to an outside party and then populate these fields with the returned data - note in some cases they may not return

Is there a way to use javaScript syntax inside Html helper

眉间皱痕 提交于 2020-01-06 04:19:50
问题 I have the following code inside my razor view:- @Html.PagedListPager(Model , page => Url.Action("Index","Server", new { searchTerm = ViewBag.searchTerm, page, sort = ViewBag.CurrentSortOrder, pagesize = $("#pagesize").val() }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(PagedListRenderOptions.ClassicPlusFirstAndLast, new AjaxOptions { UpdateTargetId = "ServerTable" , LoadingElementId="progress2" })) But i am unable to get the value of field using the following $("#pagesize").val()

ASP.NET MVC3 HtmlHelper extension method like BeginForm that uses a partial view?

倾然丶 夕夏残阳落幕 提交于 2020-01-06 01:29:23
问题 I created an extension method based on this answer to the SO question c# - How can I create a Html Helper like Html.BeginForm - Stack Overflow and it works fine. Can I move the embedded HTML in the extension method into a partial view and use that partial view in the method while preserving it's current behavior? In particular, I want to be able to 'wrap' a block of arbitrary HTML. I ask not out of any pressing need, but simply out of a desire to maintain HTML consistently, e.g. as views and

Html Helper Not Working on nested Site Master page

杀马特。学长 韩版系。学妹 提交于 2020-01-05 10:58:26
问题 I'm sure I'm doing something really stupid, but I've created a Nested Site master for one section of my app. I got the extra text to show up, like it should on the new Site Master (Greek.Master). But when I went to add some Html to Greek.Master, I found out the html helper isn't working. Here's my nested master <%@ Master Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Greek.master.cs" Inherits="PaleLocust.Views.Greek.Greek" %> <asp:Content ID=

Elegant and efficient way for Django templates?

一曲冷凌霜 提交于 2020-01-05 02:59:09
问题 I find myself ending up with template snippets in the following style: <ul> {% for item in items %} <li><a class="{% if item.active %}active{% endif %}" title="{{ item.title }}" href="{{ item.get_absolute_url }}"><img src="{% thumbnail item.image 24x24 crop upscale %}" />{{ item.title|truncate_chars:30 }}</a></li> {% endfor %} </ul> A while ago ai had to use a PHP framework which had some nice helpers for HTML output. I know that this cannot be directly compared, as it is not a real template