Skip to content

Instantly share code, notes, and snippets.

View gavilanch's full-sized avatar

Felipe Gavilán gavilanch

  • República Dominicana
View GitHub Profile
// Versión 1
namespace WebApiSwaggerVersion.Controllers.V1
{
[ApiController]
[Route("api/v1/[controller]")]
public class WeatherForecastController : ControllerBase
{...}
}
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Text;
@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - BlazorApp_Scaffolding3.Server</title>
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace BlazorMovies.SharedBackend.Helpers
{
function initializeCounterComponent(container) {
var chart = container.querySelector('#myChart');
inicializarChart(chart);
var button = container.querySelector("#counterClick");
var title = container.querySelector("h1");
if (button) {
button.addEventListener("click", (e) => {
let button = e.target;
button.innerHTML = "Hello";
title.innerHTML = "The button has been clicked!";
@page "/counter"
@inject IJSRuntime js
<div @ref="container" class="counter-container">
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<div class="form-group">
<button id="counterClick" class="btn btn-primary counterClickC" @onclick="IncrementCount">Click me</button>
</div>
function initializeCounterComponent(container) {
var boton = container.querySelector("#counterClick");
var title = container.querySelector("h1");
if (boton) {
boton.addEventListener("click", (e) => {
console.log("click JavaScript");
let button = e.target;
button.innerHTML = "Hello";
title.innerHTML = "The button has been clicked!";
});
@page "/counter"
@inject IJSRuntime js
<div @ref="container">
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button id="counterClick" class="btn btn-primary counterClickC" @onclick="IncrementCount">Click me</button>
<button @ref="myButton" id="counterClick" class="btn btn-primary counterClickC" @onclick="IncrementCount">Click me</button>
@code {
private ElementReference myButton;
protected async override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await js.InvokeVoidAsync("initializeCounterComponent", myButton);
$(document).on("click", "#counterClick", function (e) {
$(this).html("Hello");
});