Questions tagged [razor]

0

votes
0

answer
12

Views

Asp.net form: Why are the lists send after submit empty?

I know there are tons of examples that should solve my problem. I did all I could but still could not fix my problem. I have a form which will be generated based on the PersonList. When I fill in the form for each person and its address and press submit, the personList and AddressList count is set t...
FFBbodie
0

votes
0

answer
3

Views

.NET Core Razor Template - Yield to content in partial

I've done this with other templating systems and I'm not sure how to do it with .NET Core Razor templates. I have a _Tabs partial and I want to pragmatically use different partials in each tab's content, ie a _Table or _Content partial. So for example, given the following two partials: // _Tabs.csht...
JDillon522
1

votes
2

answer
4.8k

Views

Asp.net MVC and Chart js

I want to show data that comes from databse with chart.js. In asp.net MVC i have a controller that retrieves data from the database and shows them in view with the following code: @foreach(var items in Model) { @items.title @items.cuntr } How can I show @items.title and @items.cuntr in chart.js? Th...
masoud amirian
0

votes
0

answer
7

Views

how to set focus in mvc layout for specific page

the following 3 links are in my layout page i am trying to create a focus element for the item class when i use CSS, each time the layout page is refreshed with the link and the element looses its focus @Html.ActionLink("Home","Index","Home",new{area=""},new {@class="item"}) @Html.ActionLink("Abo...
kushal
0

votes
1

answer
107

Views

how to properly fix MVVM scaffolding issue with duplicate name tag? (ASP Core 2.2)

Here's my problem, I have a Book that contains List that contains List and I'm trying to create a view that will edit my book. This view contains all the lines from the book. I've made an MVVM for List that calls smaller MVVM for List. The problem is that MVVM is not counting all Line as one single...
MathieuAuclair
1

votes
3

answer
43

Views

How to properly use Model Binding to get Radio Button value in Razor Pages

I have a set of radio buttons on a razor page, and I want to get and use the selected value of these radio buttons in my server-side code once the form has been submitted. HTML for radio buttons: 1 2 3 4 I am using model binding to get the value on the server-side: public class BoostNo { [Required(E...
bbbb
1

votes
0

answer
15

Views

Razor Pages .NET Core 2.1 Child Routes

I'm working on a .NET Core 2.1 Razor Pages application, and can't figure out why the router isn't matching my expectations. In my application an Orchestration object has a collection of Rules objects. An Orchestration is defined queried at the DB with a Guid. My Index.cshtml in the Orchestration f...
wootscootinboogie
0

votes
1

answer
31

Views

Form in Layout: Razor Pages

I have a select in a form in the Layout of my web app that needs to be accessible from every page. The form sets a session variable that is required to load data on every page. Select Customer Vandalay Kramerica I know I can make a base PageModel and inherit from that on every page in order to resp...
Steven B.
1

votes
1

answer
1.1k

Views

Setting ASP.NET Core TagHelper Attribute Without Encoding

I want to add the integrity attribute to a script tag in my tag helper. It contains a + sign which I don't want encoded. This is my tag helper: [HtmlTargetElement(Attributes = "script")] public class MyTagHelper : TagHelper { public override async Task ProcessAsync(TagHelperContext context, TagHelpe...
Muhammad Rehan Saeed
0

votes
0

answer
4

Views

How to use depencey injection pattern with custom external .NET Standard DLLs

I am new to ASP.NET Core so excuse me in advance if my question is vague. I have been reading about the Dependency Injection pattern and I think its great but I have not been able to find an example of how to make use of this pattern with external dlls built with .Net Standard. I am starting a new p...
kaurivlore
1

votes
2

answer
3k

Views

Sort child nodes by date - Razor Umbraco

For the following examples, I'm using a content tree which looks like this: Content tree @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var home = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "BlogContainer"); @foreach (var item in home) { foreach (var items in item.Children) { fo...
Goran Hrustić
1

votes
2

answer
1.1k

Views

Razor input element custom attribute

Hi I need to do the following: @Html.TextBoxFor(m => m.Login, new { @class = "form-control", @placeholder = "Username", required="true" data-required-message="Please insert your name" }) But Im getting error on data-required-message seems that I can't use "-". Any clue?
VAAA
1

votes
2

answer
185

Views

Render strings on a cshtml from a class with constants

I have a public class like this: namespace MyProgram.Common { public static class UIStrings { public const string Title = "Hellow World" public const string SubTitle = "This is another string. Please click on 'Here'" } } And then, on my Index.csthml I have the following code: @Myprogram.Common.UiStr...
user3587624
1

votes
2

answer
824

Views

Passing multi parameters from view to controller using array

I would like to post between 55 and 100 items which could be false or true from view to my controller without using Model. This is my code in Razor View: @using(Html.BeginForm( "User","User",FormMethod.Post,new{enctype="multipart/form-data"})) { Choice one Choice two Choice three Choice four .... Ch...
Esmael
0

votes
0

answer
8

Views

How to transfer a list or array to a controller using a model in a view?

Using the model, I need to transfer form data from view to controller. @model EditFormApplication.Models.NewForm @using (Html.BeginForm("EditForm", "Home", FormMethod.Post)) @Html.EditorFor(model => model.HeadForm) @Html.EditorFor(model => model.HeadField) The "Add Field" button adds another div cla...
0

votes
0

answer
4

Views

Redirect to Page with ID in Razor Pages

I'm trying to get my app to redirect to the previous page after it updates the database but I can't seem to figure it out. What's complicating it is that the previous page isn't just a simple page. It's populated with information pulled but a specific row in the database so the URL has blah blah bl...
athomas
1

votes
4

answer
2.5k

Views

How to add jQuery UI to Asp.Net Core VS2017?

I have installed jQuery UI using Bower in VS2017. When I look in Solution Explorer I can see that the Bower package seem to have been installed but I can't find them in the wwwroot folder so I don't know how to add them to the _layout.cshtml file. What is the procedure for adding jQuery UI to my AS...
Thomas Adrian
1

votes
2

answer
1.2k

Views

Calling a Web API from ASP.Net Core 2 Web App using Razor

I've done quite a lot of research on this topic but can't seem to find an answer. I have written an ASP.Net Core 2 Web API. I am now wanting to develop a front end. I have been looking at using ASP.Net Core 2 Web App using razor, however I am struggling to call my web API. All the ASP.NET guides see...
CraigWake
1

votes
1

answer
76

Views

Disable get request on logout razor page

I have a razor page (asp.net core 2.1) for logout (/identity/account/logout) which shows its view on get request and perform logout on post request. I want to remove the view and leave only the logic for logout which is the post request. I deleted OnGetAsync() method from the PageModel, but the view...
Iliyan Ivanov
1

votes
1

answer
372

Views

How do you create a confirmation message in .net Core 2.1 RazorPages?

Hopefully not a dumb question- I am rewriting an app from .net core mvc to .net core Razor. In MVC I use viewbags to create and display confirmation of actions being successful or display error message if not. Viewbags don't seem to be used or available in the same way for Razor pages in .net core 2...
Lyndon Sundmark
1

votes
1

answer
147

Views

Calling Action in Razor Pages

as a newbie to Razor Pages I have a question regarding calling methods from Razor Page. I have a method called subtractProduct defined in my domain model. In my Index Page code I define IActionResult sellProduct which calls subtractProduct on specified ProductId. But I have no clue how to call thi...
xcelm
1

votes
2

answer
33

Views

News page with headline list in sidebar

I'm pretty new to MVC. I'm trying to create a page where a news story is pulled from a SQL Server database to populate the main area of the page, while I have a sidebar where all the headlines are listed. I've tried using a partial view for the sidebar. Here's the code from the controller which po...
John
1

votes
2

answer
50

Views

Radio button is checked by default when checked property is false?

I am trying to generate radio buttons, checking the checked property conditionally if the value exists in database then it should be selected otherwise checked property is false. so initially there are no rows in the database and the checked property is also false for all the radio button but still,...
Naveen Kumar
1

votes
2

answer
61

Views

Calling ajax request from asp.net razor view

How do I initiate an ajax request (calling controller action) from razor view which returns the data in JSON format? At the moment after clicking the action link in my razor view the page does the post request which redirects the page to /actionName which of course does not exist. I am also using...
zaq
1

votes
2

answer
43

Views

In ASP.NET Razor, how to include model attribute in a string?

Is there a clean way to include a string substitution inside a razor page? That is, I have some razor code that looks like this but does not work. I feel like I'm missing some punctuation.
Pete
0

votes
0

answer
3

Views

How to show all country as well as multiple select in mvc

actually, I needed all country show in autocomplete dropdown also multiple select in MVC
Deepak Behera
1

votes
1

answer
374

Views

in _ViewStart,cshtml, how come the Javascript part does not get executed every time when I goto another page?

In the code below which is located in _ViewStart.cshtml, for some reason, only what is inside @{ } gets executed everytime when i goto another page, but the javascript part does not, why is this and how do I fix it? alert("in side viewstate"); @{ Layout = "~/Views/Shared/myLayout.cshtml"; }
Chen Lu
1

votes
1

answer
431

Views

DateTime formatting error in the MVC view

I am developing MVC app. I am trying to format the date in view. In one statement it working fine , but in another statement showing the error. Below statement work fine. @Model.CreatedDate.ToString("dd-MMM hh:mm tt") This statement generates an error. @Model.ModifiedDate.ToString("dd-MMM hh:mm t...
bnil
1

votes
1

answer
1.3k

Views

Change default DateTime format for razor

Is there a way I can change the default formatting for all DateTime objects to e.g. "dd.MM.yyyy" in Razor ? I would like to cover cases when a programmer forgets to call an extension method or to pass a format string, i.e. @Model.MyDateTimeObject.
Tomas Grosup
1

votes
2

answer
1.3k

Views

How do you get JavaScript to alert a Razor variable?

I am trying to create a table header that alerts its text when clicked. I could not pass in a Razor variable to a JavaScript function parameter. What's a good work-around? Here is my code: @foreach (var web in Model.Webinars) { var title = web.Filename; if (!String.IsNullOrEmpty(title)) { // If file...
Marlo C
1

votes
1

answer
561

Views

MVC get variable from url (routing) in view?

In my routing I have routes.MapRoute( name: "ctrl", url: "ctrl/{target_name}", defaults: new { controller = "ctrl", action = "TheAction" } ); How do I access target_name? I tried ViewBag.target_name, I Googled and found many pages say RouteData.Values but I get a compile error CS0120: An object ref...
1

votes
1

answer
252

Views

c# nested classes the type or namespace could not be found

I have a class with nested subclasses: public class listDevicesModel { public int totalCount { get; set; } public Messages messages { get; set; } public Devices devices { get; set; } public class Entry { public string key { get; set; } public object value { get; set; } } public class Detail { public...
Lord Vermillion
0

votes
0

answer
2

Views

How to add subtext to images in sitefinity gallery?

I need to add subtext to each image in sitefinity gallery. I've tried putting each image inside a div and group it that way but that messed up gallery formatting completely. I've also tried using spans and with that I only managed to position the text using not so responsive css. @for (int i = 0; i...
tillinips12
1

votes
1

answer
723

Views

Set the page size in Jtable && razor application

I have included a new frame in my HTML-page, in this frame I have a Jtable . I need to set the default pagesize to 4 to have the included view without scoller. I made this changes: options: { paging: false, pageList: 'normal', //possible values: 'minimal', 'normal' pageSize: 4, pageSizes: [4, 25, 5...
Lamloumi Afif
1

votes
1

answer
592

Views

Is using MVC WebGrid Bad Practice

A junior developer on my team just created a screen using an MVC Helper called WebGrid. My first reaction was a classic NO! to anything that sounded like Grid / bound tech. As he demo'd the functionality, it wasn't bad, though it did use ?sort=Title type of syntax which bothers me generally. He als...
Dave Alperovich
1

votes
2

answer
323

Views

Friendly 'From' Name with asp.net Webmail helper

I am using the webmail helper in my ASP.NET razor webpages program. I am able to send emails perfectly. my question: Does the WebMail helper allow me to use a "Friendly" From name instead of only: [email protected]? for example: Webmail.From = Friendly name + email
Arvin
1

votes
1

answer
6.2k

Views

How can we add a New Row When user clicks Add New Row in WebGrid?

I faced a problem when user clicks on "Add New Row" needs to add a Row in the bottom of the web grid using MVC3 Razor.I have done this requirement by showing the Modal PopUp Dialog and adding the record in DB adding the new record at the last when pagination is enabled.But client requires to add a r...
Hemant Kumar
1

votes
1

answer
2.3k

Views

Using ASP.NET Server Controls in MVC?

On my current project I need to add a functionality that allows the user to view a thumbnail of their uploaded PDF. I've found a handy component that achieves this (the basic version is free, but it's enough for my current needs). Anyways, the control is pretty outdated (2010), therefore there does...
Mohammad Sepahvand
1

votes
1

answer
2.5k

Views

Displaying an ICollection in a View

I have a model that was auto-generated from my SQL database. class Organization { public Organization() { this.ContactTitles = new HashSet(); this.OrganizationAddresses = new HashSet(); this.OrganizationBusinessTypes = new HashSet(); this.OrganizationCountries = new HashSet(); this.OrganizationEmail...
cfisher
1

votes
1

answer
464

Views

Sitefinity Stylesheet override 5.2

I need to remove Sitefinity's out of the box styling for all elements on a master page that we create. I've poured over tons of documents but they all leave me wanting more, a cleaner, more simplistic way to achieve this. CSS overrides seem bulky, and removing it from the config file will destroy my...
nickdoesdesign

View additional questions