razor

MVC 3 - Exception Details: System.InvalidOperationException

不想你离开。 提交于 2020-01-03 04:53:31
问题 I trying get all data from my two tables but I have a lot of compile problems. Do you know where is it problem? Also I would like to declaration two tables here return "View(repository.Towar);" Now is visible one but I don`t know what should I do also this "se.Towar_zakupiony". I found solution myself: code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using SportsStore.Abstract; using SportsStore.Entities; namespace SportsStore

Refreshing parent view when a partial view's form is submitted

夙愿已清 提交于 2020-01-03 04:40:10
问题 I'm looking into using partial views in MVC3 using Razor, and I get my partial view to render and it works fine. What I'd like to do, though, is refresh the parent view when the partial view is submitted. Code in my parent view to render partial view <div id="mydiv"> @{ Html.RenderAction("Add", "Request"); } </div> Action for parent view is simple, public ActionResult Index() { List<obj> reqs = //some query return View(reqs); } In my partial view's get action I have: public ActionResult Add()

ASP.NET MVC View not rendering script tags properly

被刻印的时光 ゝ 提交于 2020-01-03 04:33:05
问题 I have a very simple MVC project, and in my _Layout.cshtml I have some js includes like so: <script src="~/scripts/jquery-2.0.3.min.js"></script> <script src="~/scripts/easing.js"></script> <script src="~/scripts/bootstrap.js"></script> However, when it renders, it renders on the page like (note the tilde on the first one): <script src="~/scripts/jquery-2.0.3.min.js"></script> <script src="/scripts/easing.js"></script> <script src="/scripts/bootstrap.js"></script> I can't seem to get it to

How to pass selected dropdownlist value to Ajax.ActionLink in MVC 4?

流过昼夜 提交于 2020-01-03 04:23:07
问题 I am trying to pass a Form value "CustomerID" (i.e.dropdownlist selected value) using Ajax.Actionlink in MVC 4. Can someone tell me what I am doing wrong here? <div class="editor-label"> @Html.LabelFor(model => model.CustomerID, "Customer Name") </div> <div class="editor-field"> @Html.DropDownListFor(model => model.CustomerID, Model.CustomersList, "-- Select --") @Html.ValidationMessageFor(model => model.CustomerID) </div> <div id="ApptsForSelectedDate"> @Ajax.ActionLink("Click here to view

How to call and refresh a partial view in MVC 5 razor?

半城伤御伤魂 提交于 2020-01-03 03:40:07
问题 How can a partial view on the create view that has to come in empty be refreshed with new data when a user selects a value from a list a values drop down? I have a tried a bunch of stuff listed on the message board as well as others and it just drills down to more errors. I just can't believe something so easy in webforms is this hard to do in MVC. I tried this both in Chrome and IE and get errors so I'm lost. I have something like this for a partial view in the shared folder: <table

MVC3 Razor httppost return complex objects child collections

牧云@^-^@ 提交于 2020-01-03 03:30:09
问题 I have not been using MVC3 for that long and think this is a flaw in my knowledge than a real issue. I have an object that has a few basic properties and then a collection of inner objects, (simplified version): public class myClass { public string Name { get; set; } public string Location { get; set; } public List<myOtherClass> Children { get; set; } } public class myOtherClass { public string Name { get; set; } public int Age { get; set; } } I have a view that is strongly typed to the

ASP.NET MVC 5 localization resources freeze and do not change language despite changing CurrentThread.CurrentCulture

戏子无情 提交于 2020-01-03 03:15:35
问题 I have an ASP.NET MVC 5 WEB Application running under a website in IIS 8 where I need to change language programmatically at runtime by a user preference that I read from a DB and store in a session variable, and this value can change during runtime with a dropdown. The problem is language resources sometimes do not change, despite the CurrentCulture does and the worse thing is they freeze at an application level making that all the other user sessions to freeze to that language too and will

Unique key applying on asp.net MVC 5 model property

心已入冬 提交于 2020-01-03 02:23:33
问题 I have User(name,password) model and Roles model(id,role).Now what I want is mapping model(id,Uid,Rid) between these two models and here Uid,Rid foreign keys also Uid should be unique. How can acheive this. I have done with foreign key and with mapping table but I stuck at unique key applying on Uid. Can anyone help me in this? Thanks in advance. public class Image { public int id { get; set; } public string Name{ get; set; } public String Password { get; set; } } //User roles class public

Set a page title from a PartialView [duplicate]

跟風遠走 提交于 2020-01-03 01:59:08
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Modifying MVC 3 ViewBag in a partial view does not persist to the _Layout.cshtml I'm trying to set a pageTitle from a PartialView Here is my code: PartialView template: @{ ((WebViewPage)WebPageContext.Current.Page).ViewBag.Title = "Page title"; } _Layout.cshtml: <title> @ViewBag.Title</title> How to do this? 回答1: That's not something that a partial should do. It's just not its responsibility to modify the parent

ASP.NET MVC 3 Routing Multiple parameters without query string

孤人 提交于 2020-01-02 21:00:36
问题 I have the below route setup but it is not coming out the way I am expecting. Yes I am still new to MVC. The way it is coming out is like this. http://localhost:29998/Home/States?make=Chrysler the way I want it to come out is like this http://localhost:29998/Home/Chrysler/States Then of course once you click on your state it would look like this. http://localhost:29998/Home/Chrysler/Florida I would realy love to be able to remove "home from that altogether and just leave it as http:/