razor

OnMouse event Tooltip for @Html.Grid

吃可爱长大的小学妹 提交于 2019-12-14 03:58:46
问题 I use MVC3 Grid to show Events. What I need is somehow integrate on mouse event for the "NAME" to show "Description" of the item. How do I can implement? Thanks for any clue!!! @{ var grid = new WebGrid(source: Model.Events, defaultSort: "Name", rowsPerPage: 20); } @if (Model != null) { @grid.GetHtml( tableStyle: "grid", headerStyle: "head", alternatingRowStyle: "alt", rowStyle: "row", selectedRowStyle: "selected-row", columns: grid.Columns( grid.Column("Name", "Event", style: "column"), grid

ASP.NET MVC Razor extra whitespace rendered

大兔子大兔子 提交于 2019-12-14 03:46:01
问题 In Asp.net MVC, Razor inserts extra space between text blocks. I want to render a list this way: "1, 2, 3" but get "1 , 2 , 3". @for (int i = 1; i < 3; i++) { <text>@i</text> if (i != 2) { <text>, </text> } } Is there any ways to remove extra whitespace ? 回答1: I want to render a list this way: "1, 2, 3" Quick and dirty: @string.Join(", ", Enumerable.Range(1, 3)) Obviously a custom helper seems more appropriate to the job of formatting something in the view: public static class HtmlExtensions

asp.net mvc TextAreaFor is not getting validated as a required field

这一生的挚爱 提交于 2019-12-14 03:45:50
问题 I have a data entry field where I'm gathering notes. The note data element is required for each note. Here's my model: public interface INoteDataEntryViewModel : IMobilePageDataContract { int CourseId { get; set; } [Required(ErrorMessage = @"Note is required")] String Note { get; set; } [DisplayName(@"Note Date")] DateTime NoteDate { get; set; } } You can see that I have the Required attribute for the Note property. I'm using Razor to display the data entry form element: <div data-role=

asp.net mvc4 jquery not working

梦想的初衷 提交于 2019-12-14 03:39:57
问题 I'm trying to run a jquery code which was put in my _Layout.cshtml as below: ............... <script type='text/javascript'> $(document).ready(function () { alert('Test'); }); </script> @Scripts.Render("~/bundles/jquery") @RenderSection("Scripts", required: false) </body> </html> The above code wasn't fired and when I inspected with Chrome Dev, it showed $ is not defined ( I can see all my jquery, jquery ui files are loaded ) It worked if I put this code in an external js file I don't mind

Is Razor compulsory in ASP.NET MVC 5? [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-14 03:20:04
问题 This question already has answers here : Using ASPX View Engine with MVC 5 (2 answers) Closed 4 years ago . I am new to ASP.Net MVC 5 and I want to know if Razor view engine is compulsory, or can you use ASPX view engine? I try to create new application but I am not getting option to change the view engine. 回答1: Razor views are not compulsory. You can use aspx views. When creating your project there is a dropdown that allows you to select which view engine you want the template to use, if you

CSS Background image not displaying in ActionLink in MVC4

ぐ巨炮叔叔 提交于 2019-12-14 03:15:54
问题 I'm having an issue with the CSS in my ActionLink on the _Layout.cshtml file. I changed the "Your logo here" text to reflect an image drawn in the background through a CSS class, however it seems to not load the picture.. <p class="site-title">@Html.ActionLink(" ", "Index", "Home", null, new { @class = "sitelogo" })</p> The CSS is: .sitelogo { background: url("../Images/topLogo.png") no-repeat center right; display: block; height: 84px; width: 585px; The box is displayed in a block with the

MVC Google Map Polylines

有些话、适合烂在心里 提交于 2019-12-14 03:14:57
问题 I'm trying to create a Google Map that will draw out a race course from a list of lat & lng in my MVC model. I have successfully done this with markers but I need to do it with polylines to create a path of the course. Below is what I have but can't get the lines to show up. Any suggestions? <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=false"></script> <script> function initialize() { var mapOptions = { zoom: 10, center: new google.maps.LatLng(@Model.Courses.Latitude

Handle Session Timeout in .Net MVC Razor

喜欢而已 提交于 2019-12-14 03:13:44
问题 I am working on a website which is API based, client side is being developed in .Net MVC. For exception handling, I am using public void Application_Error(object sender, EventArgs e) { string action = "Index"; Exception exception = Server.GetLastError(); Response.Clear(); HttpException httpException = exception as HttpException; if (httpException != null) { switch (httpException.GetHttpCode()) { case 404: // page not found action = "Error404"; break; default: action = "Index"; break; } //

MVC3 Multiple PartialViews in one View

孤者浪人 提交于 2019-12-14 03:09:42
问题 The answer supplied here is exactly what i've got going on. But when I hit submit in either partialview, the output is just the html for the PartialView! I'm new to MVC3 so I'm sure I'm just missing something that I should have already learned. public ActionResult CreateV2Worksheet() { return PartialView("_NewV2WorksheetInput", new NewV2WorksheetInputModel()); } [HttpPost] public ActionResult CreateV2Worksheet(NewV2WorksheetInputModel pNewV2Input) { if (ModelState.IsValid) { ModelState

Convert response body from XML to Json in API Management Policy Expression when forwarding response to different URL

柔情痞子 提交于 2019-12-14 03:05:46
问题 How can I change the response body from XML to Json when forwarding the response to a different URL? I'm specifically forwarding the response to Azure Service Bus. I've tried many different ways to serialize XML to json but with no luck because of the restrictions of some JsonConvert methods that's not allowed in policy expressions. And no, <json-to-xml apply="content-type-json" consider-accept-header="true" /> is not the solution :) <outbound> <base /> <send-request mode="new" response