razor

Check/uncheck multiple checkboxes with Jquery

北城余情 提交于 2019-12-25 03:52:58
问题 I´ve been stuck on a minor jquery problem, it´s probably just something minor I´m not seeing yet. I have a PartialView and I want to be able to check a checkbox and it should make all the other checkboxes unchecked. I only want one checkbox checked before I submit the page. Anyway, here is my code sample: This is my PartialView @model List<int> @foreach (var element in Model) { <div id="AddedProductImages"> <img src="@Url.Action("RetrieveFile", "File", new { id = element })" alt="@element"

Resolving an image uri relative to application root

末鹿安然 提交于 2019-12-25 03:45:28
问题 I am using Asp.Net MVC 5. Assume for this question that my application is being served from localhost:9000/app . I've got this in my _layout.cshtml : <img src="@Url.Content("~/Content/logo.png")" /> When the user requests localhost:9000/app/foobar , the image URI is correctly resolved to localhost:9000/app/Content/logo.png . But when the user requests localhost:9000/app/folder/bender_is_great , the image URI resolves to localhost:9000/app/folder/Content/logo.png . How do I get the image URI

How to create session variable and retrieve in JavaScript MVC3

流过昼夜 提交于 2019-12-25 03:39:22
问题 I want to create a variable Session in JavaScript and Retrieve it in same JavaScript My Code '<%Session["Test"] = "Welcome DS";%>'; var session_value = '<%=Session["Test"]%>'; alert(session_value); its giving "<%=Session["Test"]%>" alert result, Its not giving Session values 回答1: You are using a wrong syntax that is for another version of razor. You can change it to: alert('@Session["Test"]'); Notice the use of the @ sign. You can refer to this page for the proper syntax. 回答2: ASP.NET thinks

CREATE view does not Post the create method from the controller [closed]

独自空忆成欢 提交于 2019-12-25 03:34:37
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . The create view does not post (or call the create method with the model parameter). CREATE VIEW @model Univita.LtcClaims.Models.EpisodeOfBenefitModel @{ ViewBag.Title = "Create"; Layout = "~/Views/Shared/_Layout

Sending form with Select List

强颜欢笑 提交于 2019-12-25 03:18:19
问题 I am using this code to post value of selected item from the view to the controller @using (Html.BeginForm()) { @Html.DropDownListFor(model => model.MyVar, (SelectList)ViewData["List"]) <button name="Button" value="Valider">Valider</button> } Is there a way to send the value when the selection change in the select list (without the need to click on the button) ? 回答1: yes you can do it via JQUERY, on dropdown selection change post the form via jquery: add id to drop down: @Html.DropDownListFor

In MVC Razor how to access selected drop-down value from layout in multiple controllers

匆匆过客 提交于 2019-12-25 03:06:24
问题 Problem Statement: How to access selected drop-down value from layout in multiple controllers while performing CRUD operations in views. Dropdown List in Layout.cshtml: <li>@Html.Action("Index", "LanguageDropdown", new { languageid = Request["languageId"] })</li> Partial View for Dropdown: @model ALCMS.Web.Models.Master_or_Configuration.LanguageDropdownModel <script type="text/javascript"> function GetLanguage() { var languageId = $('#LanguageId').val(); var Url = "@Url.Content("~

Is there a way in AutoMapper to specify that all strings being mapped are to be trimmed

冷暖自知 提交于 2019-12-25 02:57:36
问题 I'm converting a WinForms app to ASP.NET MVC4 and trying to implement a ViewModel approach using AutoMapper to map between the domain entities and the ViewModels, mostly to flatten the more complex object graphs into ViewModels for easy binding in the views. The problem I'm running into is that when leaving some fields blank that the domain model wants to apply a Trim() a NullReferenceException is thrown. Originally this was all handled in the domain objects for example in the Customer object

TypeError: Cannot call method 'forEach' of undefined " in d3 js on MVC Razor

回眸只為那壹抹淺笑 提交于 2019-12-25 02:48:13
问题 Why I am getting error on below code in place of data.forEach I added D3 js as well but code is not able to identified the "data.forEach".please let me know how to resolve this issue on MVC razor. my data2.csv is below date,close 1971,0.357 1972,1.927 1973,1.870 1974,2.014 1975,10.995 1976,16.227 1977,16.643 1978,20.644 1979,22.478 my scripts is below var margin = { top: 20, right: 20, bottom: 30, left: 50 }, width = 600 - margin.left - margin.right, height = 400 - margin.top - margin.bottom;

Connecting html pages + Razor to database

浪尽此生 提交于 2019-12-25 02:43:31
问题 I am doing a learning project in which i wanted to combine Html+Razor and connect it to Database. Steps I followed . Created a sample form ( which i intend to use to execute "insert" and "update" queries ) Created Database (Name: TestDatabase.mdf, located inside App_Data) Put in some sample values in the database with Table name "Student" updated the webconfig file as follows (ConnectionString was obtained by copying it from Database explorer) <connectionStrings> <add name="TestDatabase"

MVC Retrieve Multi Entry from View in Controller

冷暖自知 提交于 2019-12-25 02:42:06
问题 this is my controller: public ActionResult Create() { Number newNumber = new Number(); return View(newNumber); } and View : @model PhoneBook.Models.Number @{ ViewBag.Title = "Create"; } <h2>Create</h2> <script src="../../Scripts/jQuery.AddNewNumber.js" type="text/javascript"></script> @using (Html.BeginForm()) { @Html.ValidationSummary(true) @Html.HiddenFor(model => model.Contact.Id) <fieldset> <legend>Number</legend> <div class="TargetElements"> <div class="editor-label"> @Html.LabelFor