razor

HtmlAttributes in Extension Method

梦想的初衷 提交于 2019-12-22 07:12:40
问题 I'm using MVC 5 and I'm trying to write some Bootstrap extention methods. My goal is to 'overwrite' the Html.ActionLink method with Html.BootstrapLinkButton . The BootstrapLinkButton method should generate a link with the css classes "btn btn-default" automatically attached. My code so far: public static MvcHtmlString BootstrapLinkButton(this HtmlHelper htmlHelper, string linkText,string actionName, string controllerName, object routeValues = null, object htmlAttributes = null) { var

Date field does not display the value in Chrome browser

让人想犯罪 __ 提交于 2019-12-22 07:05:48
问题 I am having problem binding date value in Chrome browser. My razor view defined as follow <input id="date1" type="text" class="required" value="@Model.Date.ToShortDateString()" maxlength="10" /> <input id="date2" type="date" class="required" value="@Model.Date.ToShortDateString()" maxlength="10" /> I ran it under Chrome, the first input display the date value correct. the second input only display mm/dd/yyyy even though a calendar display when I click on the down arrow. I would like to have

how to send text box value as parameter on form submit in mvc3 asp.net

纵然是瞬间 提交于 2019-12-22 06:28:33
问题 i have created partial view in MVC3. now i want to send text box value as parameter of form submit on pressing the submit button my partial view is like @using (Html.BeginForm("Searching", "AccountManager", FormMethod.Post, new { name ="Wat should i put here" })) { <input id="account" type="text" class="s" /> <input id="Search" type="submit" class="b" value="hi" /> } and my controller is like public viewResult Searching(string name) { // bussiness logic return view(); } 回答1: Simply give your

Reusable editor template with DropDownList for business objects

我与影子孤独终老i 提交于 2019-12-22 06:13:56
问题 I'm using MVC3 with Razor views and would like to build reusable DropDownLists for several of my classes, but after much searching I have not found an example that performs exactly how I need it... For this example I have two classes like this:- public class Person { public int ID { get; set; } public string Name { get; set; } public Group Group { get; set; } } public class Group { public int ID { get; set; } public string Name { get; set; } } I have a working Controller/View for Person. The

Remove HTML formatting in Razor MVC 3

耗尽温柔 提交于 2019-12-22 06:11:35
问题 I am using MVC 3 and Razor View engine. What I am trying to do I am making a blog using MVC 3, I want to remove all HTML formatting tags like <p> <b> <i> etc.. For which I am using the following code. (it does work) @{ post.PostContent = post.PostContent.Replace("<p>", " "); post.PostContent = post.PostContent.Replace("</p>", " "); post.PostContent = post.PostContent.Replace("<b>", " "); post.PostContent = post.PostContent.Replace("</b>", " "); post.PostContent = post.PostContent.Replace("<i>

Reusable editor template with DropDownList for business objects

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 06:11:24
问题 I'm using MVC3 with Razor views and would like to build reusable DropDownLists for several of my classes, but after much searching I have not found an example that performs exactly how I need it... For this example I have two classes like this:- public class Person { public int ID { get; set; } public string Name { get; set; } public Group Group { get; set; } } public class Group { public int ID { get; set; } public string Name { get; set; } } I have a working Controller/View for Person. The

Remove HTML formatting in Razor MVC 3

和自甴很熟 提交于 2019-12-22 06:11:03
问题 I am using MVC 3 and Razor View engine. What I am trying to do I am making a blog using MVC 3, I want to remove all HTML formatting tags like <p> <b> <i> etc.. For which I am using the following code. (it does work) @{ post.PostContent = post.PostContent.Replace("<p>", " "); post.PostContent = post.PostContent.Replace("</p>", " "); post.PostContent = post.PostContent.Replace("<b>", " "); post.PostContent = post.PostContent.Replace("</b>", " "); post.PostContent = post.PostContent.Replace("<i>

Can I change the search order for the physical views of an ASP.Net MVC 3 application

妖精的绣舞 提交于 2019-12-22 05:53:08
问题 I noticed Asp.net MVC 3 searches for .aspx files before .cshtml files. Can I change this search order? And how to do this? Background information When debugging I got the following exception: The view 'Reset' or its master was not found. The following locations were searched: ~/Views/Demo/Reset.aspx ~/Views/Demo/Reset.ascx ~/Views/Shared/Reset.aspx ~/Views/Shared/Reset.ascx ~/Views/Demo/Reset.cshtml ~/Views/Demo/Reset.vbhtml ~/Views/Shared/Reset.cshtml ~/Views/Shared/Reset.vbhtml I conclude

ASP.NET MVC Form loaded via ajax submits multiple times

南笙酒味 提交于 2019-12-22 05:29:12
问题 I have a partial view containing an ajax form. This partial view is loaded onto my page via an ajax call. I can edit the fields and submit the form and everything works normally. However, if I reload the form N times, the form will submit N times when the save button is clicked. here is the code for the partial view.... @model blah blah... <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type=

Razor - using foreach, insert html every nth item

落花浮王杯 提交于 2019-12-22 05:23:12
问题 I'm outputting a large list of items on my page using Razor and MVC 5. Here's what I have currently: @foreach (var item in Model.Items) { <a>@item.Name</a> } What I'm trying to do is something that would output this: <div class="tab-0"> <a>Item 1</a> <a>Item 2</a> <a>Item 3</a> <a>Item 4</a> </div> <div class="tab-1"> <a>Item 5</a> <a>Item 6</a> <a>Item 7</a> <a>Item 8</a> </div> <div class="tab-2"> <a>Item 9</a> <a>Item 10</a> <a>Item 11/a> <a>Item 12</a> </div> I need to group every 4 items