razor

How do I call a post actionresponse passing the selected dropdown item as a parameter from javascript within a view

爱⌒轻易说出口 提交于 2020-01-06 08:48:07
问题 How do I call a post actionresponse passing the selected dropdown item as a parameter from javascript within a view within asp.net, razor, mvc Basically, as I'm sure you can tell from the below code, I'm trying to accomplish the above without much success. What should I change to be successful? Thanks <script type="text/javascript"> $(function() { $("#mydropdown").change(function() { var selectedItem = $(this).val(); $.ajax({ url: '@Url.Action("DoStuff", "MainController")', type: "Post", data

MVC Grid (VB): Show details on hover

為{幸葍}努か 提交于 2020-01-06 08:31:41
问题 I've searched for this online for several hours today and found some useful stuff, but I can't get this to work 100% as I'd like. If anyone can help that would be fantastic! In my code below, I've removed anything which could expose data which the business I work for may not want to share, they will be indicated with "< SOMETHING>" Here's my problem: I'm populating an MVC grid @Html.Grid(Model.Activities).WithModel(New <CLASSNAME HERE>(Html)).Sort(ViewData.Item("actgridsort")) this part works

Strange behaviour with MVC posting list

痞子三分冷 提交于 2020-01-06 08:28:06
问题 I have the following dynamically created textboxes in my view: @for (int i = 0; i < Model.MullionList.Count; i++) { ItemDrops curMullItem = Model.MullionList.ElementAt(i); <div class="form-group"> @Html.Label(curMullItem.ItemName.ToString(), new { @class = "col-sm-6 control-label" }) <div class="col-sm-6"> @Html.TextBoxFor(x => x.MullionList[i].ItemPossInfo, new { @class = "form-control" }) @Html.HiddenFor(x => x.MullionList[i].ItemName) </div> </div> } I noticed occaionally for certain types

MVC 4 (razor) - Controller is returning a partialview but entire page is being updated

情到浓时终转凉″ 提交于 2020-01-06 08:22:10
问题 I'm new to MVC 4 and the Razor engine - so this might be a dumb question. What I'm trying to achieve is I have a page with a drop down list and a button. Clicking the button calls the controller passing the value selected. The controller should return a partial view and only the bottom part of the page should be updated. However I'm finding that the entire page gets replaced with just the partial view html. Ie. I get my list of results displaying but I lose my dropdownlist of projects and

Instantiating and Invoking TagHelpers Manually

两盒软妹~` 提交于 2020-01-06 07:59:30
问题 This is a follow up question to this question, which seems to be for an older ASP.NET Core version (I'm using 2.1). I'm trying to call a TagHelper manually from within a TagHelper. Applying the Answer in the linked question above, the TagHelper.Process looks like so: public override async void Process(TagHelperContext context, TagHelperOutput output) { var anchorTagHelper = new AnchorTagHelper { Action = "Home", }; var anchorOutput = new TagHelperOutput("a", new TagHelperAttributeList(),

Which is the best way to use multiple models with sames properties and using a unique view?

筅森魡賤 提交于 2020-01-06 07:25:11
问题 For example, I have 3 models with an Id (int), a Name (string) and an active (bool). It's possible to use just one view for these models with the same properties ? A technique like a generic object ? Inheritance ? It's to avoid to write multiple views with the same HTML code. 回答1: You could create a ViewModel. For sample: public class CustomerViewModel { public int Id { get; set; } public string Name { get; set; } public bool Active { get; set; } } And create another ViewModel with a type

c# asp.net: add element to a list in a model using form

痴心易碎 提交于 2020-01-06 07:17:14
问题 I apologize for my very poor terminology, but I'll try to explain myself better: give a model that contains a list of obj and an obj I want a form in my view to send the obj (and the list )to the controller the controller to add the obj to the updated list and send it back to the view. my problem is passing the "initial" list to the form on submit; this doesn't work: <div class="form-group"> @Html.HiddenFor(m => m.RequestList, Model.RequestList) </div> Edit: answering to... This question may

javascript error on ext.net

橙三吉。 提交于 2020-01-06 07:14:38
问题 I am new on ext.net framework and I require lots of help. To begin with the problem I managed to solve the problem regarding the web.config file. Now I can use the ext.net with ease and no references problem has arrived but now I am having trouble running the code. As I debug and run the desired solution the error pops up regarding the java script. The error says Microsoft JScript runtime error: 'Ext' is undefined . I have no idea about the error and it will be helpful if any of you guys

How do I use the DropDownList in ASP.NET MVC 3

雨燕双飞 提交于 2020-01-06 06:10:13
问题 I am new to MVC and am trying to populate a DropDownList in my view with a list of 'rules' from my controller. When I do it the way listed, I just get a dropdownlist with a bunch of items that say CellularAutomata.Models.Rules. I know I am doing this incorrectly, I'm just wondering how I actually get it to show the rule description for each rule in the dropdownlist. I have a Model public class Rule { public int ID { get; set; } public int Name { get; set; } public string Description{ get; set

Refer to an other columns value in a MVC3 Razor WebGrid

℡╲_俬逩灬. 提交于 2020-01-06 04:20:28
问题 I have a webgrid presenting data grouped by weeks. The first grid column contains the weeknumber as seen below in the code example. The last "Summary" column needs to show different content depending on if the rows weeknumber match the current weeknumber or not. Is it possible to use the Weeknumber column value from them Summary column in some way? @grid.GetHtml(tableStyle: "grid", headerStyle: "head",columns: trainingGrid.Columns( grid.Column("WeekNumber", "Week"), ..... grid.Column("Summary