Questions tagged [asp.net-mvc-views]

A view is a standard (X)HTML document that can contain scripts. You use scripts to add dynamic content to a view.

To make it easier to add content to a view, you can take advantage of something called an HTML Helper. An HTML Helper, typically, is a method that generates a string. You can use HTML Helpers to generate standard HTML elements such as textboxes, links, dropdown lists, and list boxes.

167 questions
0
votes
1 answer

Retrieve value of Dictionary based on key, in MVC view

Im trying to get the value based on key from a dictionary with the following statement: It just throws NULL reference exception, but I do have a Key value pair with the key "MyKey" @Model.DictionaryTest["MyKey"] Should I be using a List of…
Siddharth Dinesh
  • 345
  • 4
  • 13
0
votes
1 answer

how to download partial view as a word document in asp.net mvc?

I want to download a partial view as a word document in asp.net mvc. I'm using Xceed Words Library. Here is my code. public FileStreamResult Download() { DocX document = DocX.Create(@"Test.docx"); //appending paragraph text …
Mazdaq
  • 53
  • 12
0
votes
2 answers

Form not getting rendered properly in MVC View

I am trying to generate list of skills with delete button in my view. Used a form tag to implement delete functionality using [HttpPost]. But problem is form is not getting generated properly. My table rows are not getting generated inside the form,…
0
votes
1 answer

How would I return a viewModel from a form on a view to the Controller

my model looks like this: Bank Other LawFirm | | | BankContact OtherContact LawFirmContact |______________|________________| | | Contact So when…
0
votes
1 answer

How to add two text boxes texts to html table with button click and increment rows dynamically?

I have a drop-down list, two textboxes, add button and a table. There are two things which I need to do. First thing is, fill one textbox with the drop-down list's selected text and the user will enter a value in second text box. I could find a…
0
votes
0 answers

Can a view belong to more than one controller?

I am moving a web forms project to MVC and one part of the app has a table that has all jobs in the database. it also has links to see all jobs within the thirty days and 60 days. wondering if i have to make a new view for each of the functionality…
Ha66y-Day
  • 197
  • 1
  • 2
  • 12
0
votes
1 answer

Posting value to web api method from ajax call why going null?

I am posting some values to web API method when I debug it's showing null values. Below is a snipet code of ajax call, here I am passing dept_name but it's showing null in web API method. var _customer = {}; _customer.DepartmntName =…
0
votes
1 answer

How can you get the current View's Model name?

I would expect this to be asked/answered a hundred times, but the only answer I can find anywhere on the entire Internet is: var currentModel = Model.GetType().Name; This almost works but for example if the Model is defined as @model…
ohanaman
  • 35
  • 1
  • 8
0
votes
1 answer

Get cell DisplayName from strongly-typed-list cell by List only (empty list)

I have a list of "Book" (e.g.) as a model in view @model List I want to create a table that each column get it's header by Book's DisplayName propery: @Html.DisplayNameFor(modelItem =>…
shdr
  • 868
  • 10
  • 25
0
votes
1 answer

Optional sections appear to be required

I have a Layout page which has the following @RenderSection("Style", required: false) @RenderSection("Scripts", required: false) @RenderBody() My project was working just fine until a few days ago, now all the new views I create I get the…
Mr.K
  • 1
  • 2
0
votes
0 answers

Chart Helper Asp.Net MVC displaying chart partially in view

So I have managed to create a graph based on current user data and I am attempting to tidy up the view. So far the view is taking up the whole page and hiding my navbar etc. I have tried to wrap it in div's, body, but cannot get it to work. I am not…
0
votes
1 answer

Pass string model back to controller (MVC Form)

I've searched everywhere for an answer to this question, perhaps I am unlucky. This is such a simple thing but I'd rather start here just in case it takes me longer than expected. So I have the simplest view ever. @model System.String @using…
hack3rfx
  • 573
  • 3
  • 16
0
votes
3 answers

Create a view (index) to show a list of records for a specific id?

Morning folks, Im using c# within my mvc project. i have an index view that lists household members. This works fine and pulls back the all of the records in the database. public ActionResult Index() { List houseRecords =…
Betty Lazzari
  • 99
  • 1
  • 6
  • 13
0
votes
2 answers

Displaying HTML from a Database by using MVC 3 (ASPX ViewModel)

I'm using MVC 3 (the ASPX ViewModel) while I store and display data from my SQL database. I've tried using the raw input to store it as well as using HttpUtility.HtmlEncode. Neither are working when I try to display. I've tried using the…
Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95
0
votes
1 answer

How to highlight a filed cell when user clicks on a button

I have build a system which allows clients to complete a questionnaire. in order to complete the questionnaire the user has to enter their unique number which pulls their data from a different database using by a stored procedure. Anyway what I am…
cazlouise
  • 77
  • 1
  • 3
  • 11