razor

How do I edit default Razor Creat/Edit scaffolding in Visual Studio 2010

与世无争的帅哥 提交于 2020-01-12 08:52:10
问题 is there a way I can hack out the fieldset and legend tags in the VS2010 MVC razor view templates? I've had a bit of a look through the C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE directory but I can't find what I'm looking for. 回答1: If it is specific to your project, what you can do is copy the default templates to your project and modify them. The MVC razor view templates are located in: <Visual Studio Installation Path>\Common7\IDE\ItemTemplates\CSharp\Web\MVC 3\CodeTemplates

MVC 3 Razor Form Post w/ Multiple Strongly Typed Partial Views Not Binding

≡放荡痞女 提交于 2020-01-12 05:27:50
问题 I'm curious about whether the approach of using multiple strongly typed partials within a form that posts back to the partial containing View is the right MVC approach to doing things. The main View is bound with the following model with several other properties and data annotations omitted for brevity: public class AccountSetup : ViewModelBase { public bool TermsAccepted { get; set; } public UserLogin UserLogin { get; set; } public SecurityQuestions SecurityQuestions { get; set; } } public

If value is null put an empty string on razor template?

喜你入骨 提交于 2020-01-12 02:30:15
问题 I have a razor template like below. I want to check if the value in the input field is null, put a empty string, if the @UIManager.Member.EMail has a value, put its value. How can I do that? Normal Input: <input name="EMail" id="SignUpEMail" type="text" class="Input" value="@UIManager.Member.EMail" validate="RequiredField" /> Razor Syntax Attempt: <input name="EMail" id="SignUpEMail" type="text" class="Input" validate="RequiredField" value="@(UIManager.Member == null) ? string.Empty :

MVC model boolean display yes or no

ⅰ亾dé卋堺 提交于 2020-01-11 20:11:26
问题 i have a boolean field in my model in mvc 4 entity framework 4.5 i want to display the field in my view i use this call @item.isTrue but i got true or false, i want to get yes when true and no when false what should i do please? 回答1: In your view: @(item.isTrue?"Yes":"No") 回答2: You could use a custom html helper extension method like this: @Html.YesNo(item.IsTrue) Here is the code for this: public static MvcHtmlString YesNo(this HtmlHelper htmlHelper, bool yesNo) { var text = yesNo ? "Yes" :

Render link containing span in ASP.net MVC Razor?

喜欢而已 提交于 2020-01-11 14:31:10
问题 Rendering a simple link is easy: @Html.ActionLink("About this Website", "About") But how would you write the following in razor syntax: <a> <span>Hello, I'm inconvenient!</span> </a> Appreciate any point in the right direction :) 回答1: I'm not sure I follow your example properly as it doesn't contain a link and the text for the link is different to that of the span but something like this should give you a general idea: <a href='@Url.Action("About")'> <span>Hello, I'm inconvenient!</span> </a>

Export html table into CSV file , always return empty file

China☆狼群 提交于 2020-01-11 12:14:54
问题 I am working on an asp.net mvc5 web application. and i need to implement a functionality to export an Html table into a .csv file . so i added the following link :- <a href="#" class="export">Export Table data into Excel</a > and i have the following script:- $(document).ready(function () { function exportTableToCSV($table, filename) { var $rows = $table.find('tr:has(td)'), // Temporary delimiter characters unlikely to be typed by keyboard // This is to avoid accidentally splitting the actual

mvc razor editable DropDownList

一个人想着一个人 提交于 2020-01-11 10:22:40
问题 I am looking for a code to make the dropdown list editable in MVC razor. @Html.DropDownList provides the standard select list, but the values are not editable. I tried an example from a tutorial, but it does not seem to work. 回答1: First need to add the script reference to the page: <script type="text/javascript" src="jquery.editable-select.pack.js"></script> This If you host this script on your server. You only need to set the id on you razor definition of the dropdown and then do this: $('

Why is IIS Express returning HTTP 500 errors loading javascript and CSS?

别来无恙 提交于 2020-01-11 10:00:10
问题 I am trying to develop an ASP.NET MVC5 solution using IIS Express for local debugging. Frequently, Chrome will report HTTP500 errors trying to load certain JS and CSS files (some using the built in bundling and minification feature of MVC, some on their own). WTH is going on with this and how do I stop it? Thanks, Matthew 回答1: What helped worked is as follows. I am using Visual Studio 2015. Close the visual studio solution. In fact I closed the visual studio itself In the solution folder(the

Where is the site.css file located for Identity?

那年仲夏 提交于 2020-01-11 07:25:17
问题 I have an asp.net core 2.1 MVC application. I have ran the Scaffold Identity which has generated all the HTML and models used. I can't however find the css file that identity is using for its layouts? In chrome developer tools it tells me site.css is being loaded from /Identity/css/site.css and bootstrap is being loaded from /Identity/lib/bootstrap/dist/css/bootstrap.css . These files don't seem to exist anywhere in my project. Am I missing something? It's not using the site.css file that's

Asp.net MVC Razor view - CS1525: Invalid expression term '.'

六月ゝ 毕业季﹏ 提交于 2020-01-11 04:47:05
问题 I have two identical ASP.Net 4.6 MVC project, project 1 is using roslyn complier within the site which is working fine. c:\windows\system32\inetsrv>C:\Websites1\bin\roslyn\csc.exe Microsoft (R) Visual C# Compiler version 1.2.0.60325 With the second project I'm getting the error below, it's using the complier from .Net framework. c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" Microsoft (R) Visual C# Compiler version 4.6.1590.0 Line 6: @if (!Model?.Item?