我已经开始使用电子js来开发桌面应用程序.
我想知道如何用javascript函数绑定按钮点击事件,以便我可以执行其他操作.
我使用下面的HTML代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Manav Finance</title>
</head>
<body>
<input type="button" onclick="getData()" value="Get Data" />
</body>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
我的renderer.js代码如下所示:
function getData(){
console.log('Called!!!');
}
Run Code Online (Sandbox Code Playgroud)
但我得到的错误是:
未捕获的ReferenceError:未在HTMLInputElement.onclick中定义getData
难道我做错了什么?
更新
更新了HTML文档并删除了require()方法及其现在的工作:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Manav Finance</title>
<script src="renderer.js"></script>
</head>
<body>
<input type="button" id="btnEd" value="Get Data" onclick="getData()" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在尝试迁移已实现自己的用户身份验证和授权逻辑的现有应用程序。我从 .NET MVC 开始,它包含用于身份验证和授权的 Asp.NET 身份框架。我知道我可以自定义 Asp.NET 标识来使用现有的表。
但是是否可以在没有 Asp.NET Identity 的情况下使用 Cookie 身份验证?我发现这可用于 Asp.NET core,代码如下:
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, user.Email),
new Claim("FullName", user.FullName),
new Claim(ClaimTypes.Role, "Administrator"),
};
var claimsIdentity = new ClaimsIdentity(
claims, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties
{
//AllowRefresh = <bool>,
// Refreshing the authentication session should be allowed.
//ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(10),
// The time at which the authentication ticket expires. A
// value set here overrides the ExpireTimeSpan option of
// CookieAuthenticationOptions …Run Code Online (Sandbox Code Playgroud) 我已经在我的项目中实现了剑道网格。如果数据不存在,我想向网格显示“无可用记录”消息。我为我的网格将 noRecords 设置为 true 并且它按预期工作。现在我的项目中有这么多网格,所以我想为所有网格全局设置这个设置。
有没有办法实现?
这是我的示例代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Kendo UI Snippet</title>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.117/styles/kendo.common.min.css"/>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.117/styles/kendo.rtl.min.css"/>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.117/styles/kendo.silver.min.css"/>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.117/styles/kendo.mobile.all.min.css"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.1.117/js/kendo.all.min.js"></script>
</head>
<body>
First Grid:
<div id="grid"></div>
Second Grid:
<div id="grid1"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
pageable: true,
noRecords: {
template: "No data available"
},
dataSource: {
page: 1,
pageSize: 10
}
});
$("#grid1").kendoGrid({
columns: [
{ field: "name" },
{ …Run Code Online (Sandbox Code Playgroud) 我在我的项目中集成了 Entity Framework 和 CodeFirstStoredProc 库。我想记录两个库执行的查询。以前我使用 EF 提供的 Database.Log delegate,但由于我也想记录来自其他库的查询,因此我决定集成 Miniprofiler。
我使用下面的代码来获取变量中的查询日志result:
MiniProfilerEF6.Initialize();
MiniProfiler.StartNew("Test");
using (MiniProfiler.Current.Step("Level 1"))
{
DbConnection spConnection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
ProfiledDbConnection profileSpConnection = new ProfiledDbConnection(spConnection, MiniProfiler.Current);
using (EfDataContext db = new EfDataContext(profileSpConnection))
{
List<Domain.PersonEntity> data = db.Persons.ToList();
}
using (StoredProcedureContext db = new StoredProcedureContext(profileSpConnection))
{
List<GetPersonResult> data = db.GetPerson.CallStoredProc(new Domain.GetPersonParameter { IsActive = true }).ToList<GetPersonResult>();
}
string result = MiniProfiler.Current.RenderPlainText();
}
MiniProfiler.Current.Stop();
Run Code Online (Sandbox Code Playgroud)
我期望输出查询包含所有详细信息,但不幸的是我得到以下结果:
Manprit-PC at 11/15/2018 2:24:27 PM
Test = ms
> Level 1 = …Run Code Online (Sandbox Code Playgroud) .net ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
c# ×1
electron ×1
kendo-grid ×1
kendo-ui ×1
miniprofiler ×1
node.js ×1