Jump to content

Search the Community

Showing results for tags 'razor'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 4 results

  1. I was trying to learn Razor pages. I use Visual Studio, but I'm pretty new to it. I followed an official getting started guide for installation process - https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-2.2&tabs=visual-studio . Then I tried implementing an example of w3schools - https://www.w3schools.com/asp/razor_syntax.asp - "Reading User Input". VS seemed to not recognize it - it gave me errors. I did install and add "Microsoft.AspNetCore.Mvc.Razor" through NuGet (also tried installing version 2.1.3 and latest 2.2.0) and I also added "using Microsoft.AspNetCore.Mvc.Razor;" to the Startup.cs - still nothing. Maybe I need to connect it somehow? Visual studio 2017 | ASP .NET Core 2.1 Please help!
  2. I'm practicing and trying to write a table varying the opening row tags: @foreach(blah in blahs) { if (condition){ @Html.Raw('<tr>'); } else { @Html.Raw('<tr class="shaded">'); } // More row stuff here </tr> } Is there a way to do this? My editor keeps complaining about a missing <tr> tag. Is it possible to add a class to a tag using razor? What's the common practice? BTW, this is an incredible web site!
  3. Hello everyone!I need your help.I have this code: @BuildTreeView(treeView, IdCategoriaParente) @helper BuildTreeView(IEnumerable<dynamic> data, int catfiglia, int? idcategoriaparente = 1, int level = 0, string accumulatore = ""){ // // var selectRecord = ""; var nodes = data.Where(n => n.IdCategoriaParente == idcategoriaparente).OrderBy(n => n.Id); var separatore = ""; if (nodes.Any()) { if (nodes.First().IdCategoriaParente != null) { if (level > 0) { separatore = " >> "; } } if (level == 0) { /* @Html.DropDownList("Direction", new List<SelectListItem>{ new SelectListItem{ Text = "Home To School", Value = "0" }, new SelectListItem{ Text = "School To Home", Value = "1" }}, new { onchange = "getAlldata()" }) */ @Html.Raw("<select name="IdCategoriaParente" id="IdCategoriaParente">"); @Html.Raw("<option value="0">Nessuna</option>"); } foreach (var node in nodes) { if (node.Id == catfiglia) { selectRecord = "selected"; } //Funzioni.SelezionaSelect(node.Id, catfiglia) else { selectRecord = ""; } var fullText = accumulatore + separatore + node.NomeCategoria; @Html.Raw(string.Format("rn<option value="{0}" {2}>{1}</option>", node.Id, fullText, selectRecord)); @BuildTreeView(data, catfiglia, node.Id, level + 1, fullText); } if (level == 0) { @Html.Raw("rn</select>"); } } else { // @Html.Raw("<select name="IdCategoriaParente" id="IdCategoriaParente"><option value="0">Nessuna</option></select>"); }} It is working properly. The problem is that now, the result is printed on the screen with a select.I wish the result was made into a JSON format: {"...", "...", "...": ...}Can you help me?Thanks in advance
  4. Hi, I wonder if someone can help. I am trying within a WebGrid to create a link on the (using the HTML anchor tag) Asset Tag column - so then when the user clicks on an asset tag it directs them to a Display Report page - where it displays a transaction report on that particular asset. I have searched and searched the internet, and found the solution below. However it displays the following error message: Server Error in '/' Application. Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Here is my code: var db = Database.Open("assetManagement"); var sqlExtractEventDescription = "SELECT * FROM [event]";}<h2>Devices</h2>@{if(addNewOutput.IsEmpty() == false){<p class="informationMessage">@addNewOutput</p><br />}}<a href="addNew.cshtml?type=device" class="button">Add New</a><a href="editExisting.cshtml?type=device" class="button">Edit Existing</a>@{var sql = "SELECT assetTag, imei, serialNumber, eventId FROM [device] ORDER BY assetTag";var data = db.Query(sql);var grid = new WebGrid(data, canPage: true, rowsPerPage: 10);grid.Pager(WebGridPagerModes.NextPrevious);}<div id="webGridDiv">@grid.GetHtml( tableStyle: "userWebGrid", htmlAttributes: new { id = "deviceDataTable" }, headerStyle: "header", alternatingRowStyle: "alt", columns: grid.Columns( grid.Column("assetTag", "Asset Tag", format: @<text><a class="button" href="@Href("~/reports/displayReport.cshtml?type=assetTag&assetTag=" + assetTag")">@assetTag</a></text>), grid.Column("imei", "IMEI"), grid.Column("serialNumber", "Serial Number"), grid.Column("eventId", "Event ID"), grid.Column("", "Edit"))) </div> If someone could perhaps point me in the right direction as to where I am going wrong that would be great. Thanks. Kevin
  • Create New...