Questions tagged [razor]

Razor, a powerful template language embraced by ASP.NET Web Pages, ASP.NET MVC (beginning with version 3), and ASP.NET Core, revolutionizes HTML generation. By providing an abstracted layer, it effortlessly facilitates smooth transitions between HTML markup and either C# or VB code. A simple "@" sign acts as the gateway, indicating these seamless shifts between markup and code.

Send the user authentication form to a different location by using an AJAX request

I am in the process of developing a .Net Web application using ASP MVC, jQuery & AJAX. Within this application, I have a list of products. When a user clicks on the detail button of a specific product, they are taken to a details view which includes an "Ad ...

Tips on how to implement dropdownlist filtering with angularJs based on the selection from another dropdownlist

There are two dropdown lists in my code: <div class="control-group"> @Html.LabelFor(x => x.ServiceId) @Html.DropDownListFor(x => x.ServiceId, new SelectList(Model.ServiceList, "Id", "Title"), new { @class = "open" }) &l ...

Sending dynamic boolean model property via AJAX dynamically

I am facing an issue while passing a property from my model to an AJAX form. The boolean value is resolving as "true/false" and causing problems in the process. $.ajax({ url: '/Projects/SearchTable2', type: "GET", data: { sub ...

Exploring the Document Object Model to locate the adjacent sibling of a parent element

If I need to implement an event that hides the section .dependent-box whenever the element with class .radio-click-hide is clicked, what would be the best approach for traversing the elements to achieve this functionality? I have attempted the following co ...

Refresh a div on an ASP MVC page with a controller action without the need to reload the entire page

In my controller, I have implemented the following action: public ActionResult TestItemLogistic() { ControlViewModel model = new ControlViewModel(); model.itemSelected = "Logistic"; return RedirectToAction("MenuList", model); ...

using JavaScript to send numerous text box values to various views

I have a dilemma with passing values between two views. In View1, there are text boxes for entering basic information. After the customer enters this data and clicks on 'add more details', I want to transfer these details to the text boxes in Vie ...

The width of the TD element does not affect the grid

<div id="unique-example" class="k-unique-content"> <table id="unique-grid" style="float: left; position: relative"> <thead> <tr> <th width ="410px"data-field="UniqueFileName">Unique File Name ...

ASP.Net Core Razor: Troubleshooting Null JSON Value in Ajax Requests

I am currently using .Net Core Razor for my application and encountering an issue with passing values to the controller when calling the action from Ajax. Below is the script I am using: var table = $('#dataTable').DataTable(); var data = table. ...

Display various sets of data from multiple models within a single view

My project is focused on Asp.net Mvc and I am encountering a challenge in displaying multiple model data in one view. However, I do not want to showcase it in a list or grid format, instead, I prefer a Form View style. The two modal classes involved are Pr ...

What steps should I take to transform this into an ajax form?

I'm struggling with converting this code into an Ajax form. Can someone guide me on the process? @using (Html.BeginForm("", "CollaborativeProjects", FormMethod.Post, new {enctype="multipart/form-data"})) { <input type="file" name="FileUpload1 ...

What is the best approach to obtain an inventory of inputs from a particular viewpoint?

I am facing an issue where I have a list of products that require the quantities to be returned along with the reason for return. However, I cannot modify the referenced model as it has an impact on multiple values. Can someone guide me on how to retrieve ...

Using a variable in Ajax URL with Action razor syntax

I have a function that calls a method in the controller through an Action URL. However, I need to use a parameter as the name of the method, but unfortunately, this is not possible in the current implementation. function changeDropDownList(id, dropNameToC ...

How come padding-bottom isn't effective in increasing the position of an element?

My goal is to adjust the position of the orange plus sign (located in the lower right corner of the screen) so that it aligns better with the other icons, directly below them. I've tried using padding-bottom, but it doesn't seem to work, while pa ...

Using a for loop in JavaScript to dynamically display TextBoxFor(model=> model[i].prop) in an MVC application

I need some help getting this code to function correctly: $('#ddl').change(function () { $('#cont').html(''); var count = getCount($('#ddl').val()) for (var i = 0; i < count ; i++) { var html = '< ...

Tips for incorporating Action Links into your CSS workflow

<li class="rtsLI" id="Summary"><a href="javascript:void(0);" onclick="javascript:rtsXXX.OnClientTabSelected(this‌​, 0);" class="rtsLink"><span class="rtsTxt">Test</span></a></li> I have made a change by replacing th ...

Why isn't my List<string> being retrieved from the MVC Controller in an $ajax request?

I am attempting to generate customized lists in my cshtml file through an ajax request. .ajax({ type: "GET", cache: false, url: "@Url.Action("getValidationLists")", contentType: "application/json", dataType: "json", ...

The script tags encountered an issue loading the resource with a status code of 404

Currently working on an ASP.NET MVC project and encountered an issue on one of the pages. Here is the code snippet with a script included at the bottom... @model IEnumerable<PixelBox.Dtos.ItemGetDto> @{ ViewBag.Title = "Index"; } <body> ...

Filling HTML5 Datepicker Using Information from a Model

Currently, I am in the process of developing a basic scheduling application for a project. To simplify the task of selecting start and end times/dates for our events, we have included a simple DateTime picker in the source code: <input type="datetime-l ...

Tracking a razor ajax form using pace.js has never been easier with these simple steps

I'm currently exploring the use of pace.js with my Razor ajax form. The form generates a Partial View upon submission. Pace.js, as per its documentation, automatically monitors all ajax requests lasting longer than 500ms without any additional configuratio ...

Submitting Forms using AJAX in Razor with MVC3

When utilizing The MVC3 Helper to create my Ajax form, it appears as follows: @using (Ajax.BeginForm("Attended", "Lesson", new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.InsertAfter ...

Receiving a 500 status code upon converting a SqlDataReader into Json format

Getting a status 500 error and not sure where I am going wrong. When I click on the 'Getcustomers' button, the 'GetCustomers' method is called which returns JSON. Script: <script> var MyApp = angular.module("MyApp", []); ...

Several pictures are not displaying in the viewpage

I have a controller method set up to fetch files from a specific folder. public JsonResult filesinfolder(ProductEdit model) { string productid = "01"; string salesFTPPath = "C:/Users/user/Documents/Visual Studio 2015/Projects/root ...

Tick the box to activate the ability to uncheck multiple boxes when there are already a certain number of boxes checked

I am currently developing a multiple-choice form in my MVC5 app and I am struggling to find a way to disable unchecked boxes once a specific number of boxes have been checked. For example, if 3 out of 5 boxes are checked, the remaining 2 should be disabled ...

Having trouble detecting the Selection event of a Dropdown List upon loading

When a user chooses an option from the dropdown menu, I need to capture the selected item and perform an action: $("#user-list").on("change", function() { var selectedUser = $(this).find(":selected").text(); // Perform action with the selected us ...

The ASP.Net ajax file submission model appears to be empty, even though the individual variables are functioning correctly

I am facing an issue while trying to upload a file using ajax. When attempting to receive a model, it is empty; however, if I try to obtain separate values, it works fine. public ActionResult UploadImage(HttpPostedFileBase File, string UniqueCode) { // ...

Verify the content of a hidden/shown textbox dynamically with jQuery

I'm currently developing an asp.net mvc3 application. In my Razor view, I have set up the textbox in the following way: @Html.TextBoxFor(x => Model[i].FieldValue, new { @class = "yesNoNotApplicableTextbox", style = "display: none;" }) Initially, ...

Is it possible for the relative path of a gif image to become invalid when added to a div?

Question Context: In the view, I have a form that will show a loading 'spinner' gif when a user submits it. The Problem: If I place the spinner img element within its container div, the spinner is always displayed, which is not desired: https ...

Strategies for improving the efficiency of HTML and styles in a generated document

Generating the invoice printing form layout using dynamically created Razor views through RazorEngine can result in messy and hard-to-read code. The repetitive use of words like top, left, width, and height makes it challenging for human inspection and deb ...

Showcase a picture within a row of a table using Ajax in an MVC framework

Getting straight to the point, I have a similar code snippet in my Controller: return base.File(getSomeImageBitmap, "image/jpeg"); This code successfully displays the image in a new window using @Html.ActionLink. However, I want the image to be directly ...

Encountering difficulties loading a Partial View using a JQuery ActionResult request in ASP.NET Core

I've been struggling with this issue for what seems like forever. Although I can initiate the ActionResult that returns PartialView("MODEL"), I'm having trouble rendering the actual View into the div within the Index cshtml page. Here's wh ...

The html.dropdown feature is not maintaining the selected value chosen

After successfully filling out my form and submitting data to the database, I encountered a problem with the drop downs on the form not showing the selected value if the model fails validation. Although the HTML clearly shows that the value of the dropdow ...

Retrieve the file path of an uploaded image in a Razor view using jQuery Ajax

I have been facing challenges while working on an ASP.NET MVC3 application where I am developing a custom image gallery. The browser being targeted is IE9, which rules out the option of using HTML5 File API. All my code resides within a strongly typed Razo ...

Update your current status using ajax networking

I have a file named 'statusupdateform.cshtml' where I need to post the status upon clicking 'Share'. The database query is located within 'statusupdateform.cshtml'. My goal is to achieve this functionality using ajax. Once the post is made, I want the r ...

When utilizing ASP.NET Core Razor pages for file uploads and utilizing AJAX Post to send the file to an IFormFile handler, the request

I have a straightforward task that involves uploading a file and using AJAX to post it to the Index page: <input type="file" id="file-selector" accept=".txt"> Here is the corresponding Javascript: const fileSelector ...

How can I implement a AJAX GET request with a parameter in ASP.Net Core 2 Razor

Is there a way to send an AJAX GET request in my ASP.Net Core 2 Razor Application with a parameter that needs to be passed to the destination function? For instance, I have a Select field in my HTML. Depending on what value is selected, I want to retrieve ...

Absence of MVC5 Vanilla Layouts

Creating my first MVC5/Razor application from the ground up, I want to avoid including unnecessary references that cause bloat. In the Views folder, I have separate Home and Shared subfolders. The Home folder contains Index.cshtml, while the Shared folder ...

Experiencing issues with implementing shopping cart logic using KnockoutJS. Need help

The Objective Create a dynamic list of products. The Scenario Overview In my online shopping application, I want to showcase the products I add to my shopping list in a sidebar when I click the 'add button' for each product. Brief Problem Sum ...

Rely on the razor method for generating URLs

I need to direct to a specific page, so I have implemented a JavaScript function in my MVC project: function rootUrl(url) { var _rootUrl = '@Url.Content("~")'; var x = url; if (url.indexOf(_r ...

Using Razor view form with various submit buttons

In my razor view, I have a BeginForm command surrounded by a loop that generates an HTML table with a submit button in each row. My concern is how do I identify which specific row the submitted form corresponds to when sending it back to the controller? T ...

Tips for ensuring the validity of several Ajax-loaded Partial Views?

In my View called Contact, a dynamic number of Caller partial views, another dynamic number of Child partial views, and one CallNote partial view are loaded via Ajax once the document is ready. The ability to dynamically add and remove Callers and Childre ...

Transforming a web form into razor format flawlessly

I've been attempting to switch over to razor, but I keep encountering an error. <% AjaxOptions settings = new AjaxOptions(); options.HttpMethod = "POST"; %> @AjaxOptions configuration = new AjaxOptions(); options.HttpMethod = "POST ...

RAZOR - Strip image elements from variable with HTML content

In the code snippet below, I am using a helper to display content: @Html.Raw(Model.PageData.PageContent) My goal is to filter out any image tags that may be present. I have explored methods like .substring(), but they require specific indices or string n ...

"Implementing ASP.NET MVC4 with Razor: Dynamically filtering a dropdown list based on the selected value from another dropdown

Currently, I am facing a challenge where I need to filter the options of a dropdown list based on the value selected from another dropdown. Within my database, there are tables containing all countries and all cities in the world, with a foreign key linkin ...

Troubleshooting issue with RadioButton check change not updating in onPost event in ASP.Net project utilizing Bootstrap HTML and C

Having created two radio buttons, grouped them together, and applied bootstrap classes for styling; I am encountering an issue where the values of the radio buttons are not updating when clicked and submitted. Interestingly, the checkboxes on the same form ...

Using a third-party Vue component within a .NET Core Razor Page, such as Vue Cal, can be easily achieved by following these steps

Greetings esteemed individuals of Stack Overflow. I am currently experimenting with the combination of .NET Core Razor Pages and the VueJS JavaScript framework. I'm interested in utilizing the Vue Cal library to showcase a calendar view on my Razor Page. ...

Tips on styling HTML using a query value in string format

When using ASP.NET razor and SQL Server 2008 R2, I have a local variable declared in the following manner: var tsmMtd = db.QueryValue(" SELECT b.Name, SUM(subtotal) totalSUM FROM DR_TRANS a INNER JOIN Staff b ON a.Salesno = b.Staffno WHER ...

Guide to using Razor syntax in JQuery to effortlessly redirect to a different page

$(".category-sub-opition-list li").click(function () { var id = $(this).attr("id"); var category = getUrlParameter('category'); @{ var category = Request.QueryString["category"]; var cat = Model.Ite ...

Showing formatted JSON in the view using ASP.NET MVC

Is there a method to modify JSON for presentation in the interface? I am looking for a way to automatically update my API documentation when adding new properties. It would be great if I could also apply CSS styling to certain elements. This feature is som ...

Retrieve Browser Screen Width and Height using MVC3 Razor in the View

I am facing a challenge on my website where I need to generate a Bitmap dynamically and ensure it is rendered according to the width and height of the browser so that there are no overflow issues on the page. Although I have successfully created an image ...

Extract Angular-gettext annotations from a .cshtml file

I am utilizing Angular-gettext to extract strings from .html and .js files for multi-language translation via my Gruntfile.js: grunt.initConfig({ nggettext_extract: { pot: { files: { 'po/template.pot': ['**/*.html', '**/*.csh ...

Steps to refresh my View following an Ajax Post request

Working in an MVC environment, I find myself calling a Controller method from my View. The Controller method conducts some validation checks and then returns to the same view with a faulty modelstate. However, despite expecting all of my validation fields ...

What are some effective ways to manage repetitive HTML elements like headers and footers in Angular 4?

Within my Angular web project, I find myself using a variety of different headers on multiple pages. Is there a way to streamline this process by coding the header and footer once and having them automatically included in one or more pages? I am looking ...

Which design pattern should I implement to update all table rows except the initial one, while incorporating an AJAX insertion mode?

I am working with a table structure that is dynamic based on search results. The table consists of different rows including titles for categories like Organization, Category, and File. <table class="table-striped col-lg-12" id="results"> <tr& ...

Error 404 received when using Razor MVC 3 Ajax

Attempting to implement a basic autocomplete feature using jQuery AJAX with Razor MVC 3 and Visual Studio 2012, all of which are new to me. My current code is outlined below: JavaScript: $(document).ready(function () { $("#city").keyup(functi ...

Retrieving data from a WebGrid on the front end

Utilizing a WebGrid to display information in the following manner: <div id="interiorGrid"> @{ var interiorList = Model.Lists; var interiorGrid = new WebGrid(interiorList, columnNames: new ...

Passing Parameters to Razor Pages Controller

Within my controller, there exists a function as follows: public ActionResult AddSubSub(int? idOfSubsub) { return RedirectToAction("Index", new { searchword = "" }); } I am able to invoke this function without providing any parameter. I attempted the ...

Encountering a JavaScript runtime error while trying to access and interpret JSON

Currently, I'm facing a challenge with converting a C# list of string types into a JSON object. The issue arises when trying to read this JSON object later in JavaScript. On the other hand, the process seems to work fine when dealing with a C# list of inte ...

Is there a way to prevent an ajax call from refreshing the page?

I've implemented image upload functionality in my project. However, when I click the upload button and select a file, the images are displayed via an AJAX call with HTML code. Unfortunately, afterwards, the page refreshes and all form data is lost. E ...

The interaction between MVC Razor and JQuery while utilizing a data table encounters an Uncaught TypeError: the undefined element is

I need some assistance with a jQuery DataTable issue that I've encountered. Whenever I try to call the function $ ('#tablaUsuarios').dataTable(), I get an error message saying "Uncaught TypeError: undefined is not a function". @Styles.Render("~/Content/D ...

Refresh the PartialView only after clicking submit

I am struggling with updating only the contents of my partial view after clicking an input type="submit button. My goal is to refresh just the partial view and update it with the updated model from the controller code, without refreshing the entire page. S ...

enhance user interface by dynamically updating progress bar from Razor server

I have implemented a progress bar on one of my razor pages. When I call it using an onclick event, it works perfectly fine. However, the problem arises when I try to get it working from the server side. Below is the code snippet: using Microsof ...

Send a string to the controller through an AJAX request

Seeking assistance on creating a search field to find users within my system. The idea is to input the user's name into the field, then use an Ajax function to pass that name from the search field to a method in the controller. This method will return ...

What is the best way to instruct Ajax to choose the specific item clicked within a list?

I am currently working on creating a list of people on vacation and I want to calculate their return date when the "Return Date" link is clicked. I have been able to achieve this, however, whenever I click any of the buttons in the list, it always passes t ...