我想做一个星级控制,但我似乎无法找到一种方法来选择悬停时所有以前的兄弟姐妹。这种东西是否存在或者我必须使用javascript?
span {
display:inline-block;
width: 32px;
height: 32px;
background-color:#eee;
}
span:hover {
background-color:red;
}Run Code Online (Sandbox Code Playgroud)
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>Run Code Online (Sandbox Code Playgroud)
我最近从 Asp .NET Core 2.2 升级到 3.1,并且可以在剃刀页面中使用剃刀组件。除了使用 blazor 和同一个文件中的所有内容外,它们看起来基本上类似于 View Components。我试图搜索,但我没有阅读任何关于使用 Razor 组件而不是查看组件的文档。
那么问题来了……
在 Razor 页面中使用 Razor 组件而不是查看组件有什么意义?这个会比较好吗?我知道设置视图组件有点痛苦,因为您必须使用逻辑设置默认视图和代码隐藏文件,并且不能在其上使用 javascript,只能在父视图上使用。我的大多数应用程序都充满了视图组件,我想知道切换到 razor 组件有什么好处?
这返回-1,我如何从存储过程中获取实际返回值?
这是我的存储过程
ALTER PROCEDURE [Production].[Select_TicketQuantity]
@Ticket NVARCHAR(25),
@Reference NVARCHAR(20)
AS
BEGIN
declare @SQL nvarchar (4000)
SET @SQL = 'select QARTCOL as Quantidade from D805DATPOR.GCARCCR1 where NCOLGIA = ' + @Ticket + ' AND NARTCOM = ''' + @Reference + ''''
SET @SQL = N'select CONVERT(int,Quantidade) as Quantidade from OpenQuery(MACPAC, ''' + REPLACE(@SQL, '''', '''''') + ''')'
PRINT @SQL
EXEC (@SQL)
END
Run Code Online (Sandbox Code Playgroud)
C# 代码
int? quantity= 0;
try
{
quantity= await _context.Database.ExecuteSqlRawAsync("EXEC Production.Select_TicketQuantity @p0, @p1", parameters: new[] { ticket, reference});
} …Run Code Online (Sandbox Code Playgroud) 我有多个验证布尔属性,可以需要也可以不需要。如果需要它们,则需要对其进行检查以进行验证。因此我不得不构建多个 if 语句来处理每个属性。我的问题是是否有更好的方法来维护这一点,而不必为每个新属性编写 if。
public class ProductionNavbarViewModel
{
public bool IsProductionActive { get; set; }
public bool ValidatedComponents { get; set; }
public bool ValidatedGeometries { get; set; }
public bool ValidatedPokayokes { get; set; }
public bool ValidatedTechnicalFile { get; set; }
public bool ValidatedStandardOperationSheet { get; set; }
public bool ValidatedOperationMethod { get; set; }
public bool IsComponentsRequired { get; set; }
public bool IsGeometriesRequired { get; set; }
public bool IsPokayokesRequired { get; set; }
public bool …Run Code Online (Sandbox Code Playgroud) 我已经设置了一个过滤器来处理特定文件夹和其中的所有页面。我需要使用声明访问数据库。问题是我似乎无法在启动服务上使用 DI 注册我的过滤器,因为它找不到数据库连接
services.AddMvc()
.AddRazorPagesOptions(options =>
{
options.AllowAreas = true;
options.Conventions.AuthorizeAreaFolder("Administration", "/Account");
options.Conventions.AuthorizeAreaFolder("Production", "/Account");
options.Conventions.AuthorizeAreaFolder("Robotics", "/Account");
options.Conventions.AddAreaFolderApplicationModelConvention("Production", "/FrontEnd",
model => model.Filters.Add(
new LockdownFilter(
new ProducaoRegistoService(new ProductionContext()),
new UrlHelperFactory(),
new HttpContextAccessor())));
})
Run Code Online (Sandbox Code Playgroud)
过滤器。
public class LockdownFilter : IAsyncPageFilter
{
private readonly IProducaoRegistoService _producaoRegistoService;
private readonly IUrlHelperFactory _urlHelperFactory;
private readonly IHttpContextAccessor _httpContextAccessor;
public LockdownFilter(IProducaoRegistoService producaoRegistoService, IUrlHelperFactory urlHelperFactory, IHttpContextAccessor httpContextAccessor)
{
_producaoRegistoService = producaoRegistoService;
_urlHelperFactory = urlHelperFactory;
_httpContextAccessor = httpContextAccessor;
}
public async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next)
{
int registoId;
if(!int.TryParse(_httpContextAccessor.HttpContext.User.GetRegistoId(), out …Run Code Online (Sandbox Code Playgroud) 根据https://www.mikesdotnetting.com/article/343/improved-remote-validation-in-razor-pages 我按照教程并实施了 PageRemote。但是,如果应用于模型的属性并且我将模型用作属性,则它不起作用。
public class Draft
{
public int Id { get; set; }
[PageRemote(ErrorMessage = "Invalid data", AdditionalFields = "__RequestVerificationToken", HttpMethod = "post", PageHandler = "CheckReference")]
public string Reference { get; set; }
}
[BindProperty]
public Draft Draft { get; set; }
public JsonResult OnPostCheckReference()
{
var valid = !Draft.Reference.Contains("12345");
return new JsonResult(valid);
}
Run Code Online (Sandbox Code Playgroud)
在我的页面上
<tab>
<tab-item icon="fas fa-arrow-left" url="@Url.Page("../Index")"></tab-item>
<tab-item icon="fas fa-list" url="@Url.Page("Index")"></tab-item>
<tab-item icon="fas fa-plus" is-active="true"></tab-item>
</tab>
<form method="post">
<card>
<card-header icon="fas fa-plus" title="Draft"></card-header>
<card-body>
<input …Run Code Online (Sandbox Code Playgroud) 我刚刚升级到 EF 3 和我曾经工作的查询之一,现在给出了一个例外
ProductionRecords = _context.ProductionRecords
.Where(r => r.DataCriacao.Date == DateTime.Now.Date)
.Select(pr => new ProductionRecordViewModel
{
Id = pr.Id,
Operador = pr.Operador,
DataCriacao = pr.DataCriacao,
Celula = pr.Celula.Name,
Turno = pr.Turno.Name,
TotalPecasSemDefeito = pr.ReferenceRecords.Sum(c => c.Quantity),
TotalPecasComDefeito = pr.DefectRecords.Sum(c => c.Quantidade),
TotalTempoParado = pr.StopRecords.Sum(c => Convert.ToInt32(c.Duration.TotalMinutes)),
})
.AsNoTracking()
.ToList();
Run Code Online (Sandbox Code Playgroud)
当我试图用时间跨度和持续时间对集合求和时会发生异常......
我现在该怎么处理?
这是例外
InvalidOperationException: LINQ 表达式 '(EntityShaperExpression: EntityType: StopRecord ValueBufferExpression: (ProjectionBindingExpression: EmptyProjectionMember) IsNullable: False ).Duration.TotalMinutes' 无法翻译。以可翻译的形式重写查询,或通过插入对 AsEnumerable()、AsAsyncEnumerable()、ToList() 或 ToListAsync() 的调用显式切换到客户端评估。有关详细信息,请参阅https://go.microsoft.com/fwlink/?linkid=2101038。
我不明白为什么我总是收到这个例外。我尝试保护 Blazor WebAssembly
blazor.webassembly.js:1 WASM: System.MissingMethodException: 找不到 Microsoft.AspNetCore.Components.Authorization.AuthorizeRouteView 类型的默认构造函数
应用程序.razor
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<CascadingAuthenticationState>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</CascadingAuthenticationState>
</NotFound>
</Router>
Run Code Online (Sandbox Code Playgroud)
这是客户端程序.cs
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped<AuthenticationStateProvider, ApiAuthenticationStateProvider>();
builder.Services.AddAuthorizationCore(options => { });
await builder.Build().RunAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
自定义身份验证状态提供程序
public class ApiAuthenticationStateProvider : AuthenticationStateProvider
{
private readonly HttpClient _httpClient;
private readonly ILocalStorageService _localStorage;
public ApiAuthenticationStateProvider(HttpClient httpClient, ILocalStorageService localStorage) …Run Code Online (Sandbox Code Playgroud) 我需要获取一个复杂的对象数组。
这是我的 2 节课
public class Geometria
{
public int idGeom { get; set; }
public int idMatriz { get; set; }
public string Referencia { get; set; }
public int toleInf { get; set; }
public int toleSup { get; set; }
public ICollection<MedidaX> Medidas { get; set; }
}
public class MedidaX
{
public int IdRegGeo { get; set; }
public float X { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
作为 json 返回时我的预期结果基本上是这样的
{
"Geometrias": [
{
"idGeom": 1,
"idMatriz": …Run Code Online (Sandbox Code Playgroud) 我正在使用灯塔来测量页面性能,我注意到,即使我使用低分辨率背景图像并使用 javascript 加载高分辨率背景图像,即使我等到页面完全加载,它仍然会影响灯塔上的大量内容绘画......我缺少什么吗?
window.onload = function () {
const header = document.querySelector('.header');
header.style.backgroundImage =
'url(assets/img/the-image.webp)';
};
Run Code Online (Sandbox Code Playgroud)
这是该页面的链接。加载高分辨率图像时,低分辨率图像隐藏在覆盖层后面
c# ×7
asp.net-core ×5
javascript ×2
razor-pages ×2
sql-server ×2
blazor ×1
css ×1
dapper ×1
if-statement ×1
razor ×1