我有一个包含以下内容的文本框:
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp" >
<cal:ActionMessage MethodName="OnKeyUp" >
<cal:Parameter Value="$eventArgs"/>
</cal:ActionMessage>
</i:EventTrigger>
Run Code Online (Sandbox Code Playgroud)
如果我运行此命令,则会生成一条错误消息,指出"找不到Method OnKeyUp的目标".如果我从消息和方法中删除参数,那么它运行正常.
这是方法.
public void OnKeyUp(object sender, KeyEventArgs e) {
MessageBox.Show(e.Key.ToString());
}
Run Code Online (Sandbox Code Playgroud)
我不明白这是什么问题.
房产进口什么时候满意?我认为它们会在构造函数之前得到满足,因为属性在构造函数运行之前被初始化,但是以下示例ImportedClass在构造函数中显示为null.
我知道我可以通过使用ImportingConstuctor解决这个问题; 这是为了理解何时满足房产进口.
public MyClass
{
[Import]
public ImportedClass ImportedClass {get;set;}
public MyClass()
{
//Imported Class is null at this point, so nothing can be done with it here.
}
}
Run Code Online (Sandbox Code Playgroud) 以下工作,但如何将其转换为Ajax调用?
<section id="loginWindow">
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl })) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Log in Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.UserName)
@Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)
</li>
<li>
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</li>
<li>
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
</li>
</ol>
<input type="submit" value="Log in" />
</fieldset>
}
</section>
Run Code Online (Sandbox Code Playgroud) 我有一个通过ajax提交给Controller的表单.Controller从Model收集数据,然后创建一个新的ViewModel并将其传递给部分视图,然后在Client上更新.
问题是文本框没有按预期清除.消息按预期到达视图,因此没有清除TextBoxes没有意义.
然而,它似乎是一个浏览器问题,因为这是生成的HTML,注意,该值没有任何内容:
<input id="Address_Address1" name="Address.Address1" type="text" value="" />
Run Code Online (Sandbox Code Playgroud)
然而,用户看到之前输入的值.
这是控制器:
//Process Order Here
//This should clear out the ViewModel.
order = new OrderViewModel();
order.Message = "Report Added to your cart";
return PartialView("_NewOrderPartial", order);
Run Code Online (Sandbox Code Playgroud)
这是局部视图:
@model NTC.PropertySearch.Models.OrderViewModel
@using (Ajax.BeginForm("NewOrder", "Order", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "neworder" }))
{
<div id="neworder">
<table>
<tr>
<th style="width: 300px;">
<h3>Enter property address below</h3>
</th>
<th style="width: 30px;"></th>
<th style="width: 300px;">
<h3>Choose your report below</h3>
</th>
</tr>
<tr>
<td>
<div class="form">
<table> …Run Code Online (Sandbox Code Playgroud) 我在事件处理程序中有这行javascript:
var value = event.currentTarget.value; //example: 9
Run Code Online (Sandbox Code Playgroud)
然后我在switch语句中使用它.
switch (value) {
case 9:
return 12;
case 12:
return 9;
}
Run Code Online (Sandbox Code Playgroud)
问题是"value"是一个字符串而不是int.
我应该把它转换为int吗?
或者有没有办法将值作为int获取,就像用jQuery()说的那样?
或者我应该在switch语句中使用字符串?
我刚刚学习禅宗编码,并尝试这样做:
输入“lorem”并按 Tab 键将生成 50 个单词的 lorem 文本。
但是,如果我开始<p></p>,然后在标签内输入 lorem + tab,它不会生成 lorem 文本。
有一个更好的方法吗?
我在jetbrains.com上找到了这个例子
async function getWeather(cityid: number){
var weather = await getForecast(cityid);
var {t: temperature, h: humidity} = weather;
return { temperature, humidity};
}
Run Code Online (Sandbox Code Playgroud)
我理解async/await,但我试图了解最后两行发生了什么.
var {t: temperature, h: humidity} = weather;
Run Code Online (Sandbox Code Playgroud)
据我所知,这是创建一个具有两个属性的var,类型温度为t,湿度类型为h.
return { temperature, humidity};
Run Code Online (Sandbox Code Playgroud)
对我来说,这看起来像是返回一个带有两个子对象,温度和湿度的新对象.我不明白它是如何从天气对象那里得到的.
我不知道这是一个javascript问题,还是打字稿问题,所以我标记为两者.
我需要使用Entity Framework执行存储过程.
通常我称之为:
this.Context.Database.ExecuteSqlCommand("EXEC edi_UploadTransmission");
Run Code Online (Sandbox Code Playgroud)
但是,此特定存储过程包括访问链接服务器.
由于EF包装ExecuteSqlCommand在一个事务中,它失败了,因为事务中不支持链接服务器(据我所知).
有没有办法在Entity Framework中执行此存储过程而不在事务中?
我有这个在 EntityFrameworkCore 中工作的代码。
public void SaveProject(Project item)
{
var existing = _context.Projects.FirstOrDefault(a => a.Id == item.Id);
existing.Description = item.Description;
existing.IsArchived = item.IsArchived;
existing.IsDeleted = item.IsDeleted;
existing.Name = item.Name;
_context.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
它采用一个断开连接的实体,在数据库中找到它,并应用更改。
有一个更好的方法吗?
我不想调用数据库。换句话说,我希望能够将实体标记为已修改,然后调用 SaveChanges()。
有没有办法做到这一点?
我有这个有效的代码:
public async Task<IActionResult> OnGet()
{
var workbook = GenerateClosedXMLWorkbook();
MemoryStream memoryStream = new MemoryStream();
workbook.SaveAs(memoryStream);
memoryStream.Position = 0;
return File(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "hello.xlsx");
}
private XLWorkbook GenerateClosedXMLWorkbook()
{
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Sample Sheet");
worksheet.Cell("A1").Value = "Hello World!";
worksheet.Cell("A2").FormulaA1 = "=MID(A1, 7, 5)";
return workbook;
}
Run Code Online (Sandbox Code Playgroud)
但是,在我看来,我需要以某种方式关闭或处理 memoryStream。那是对的吗?还是会自动关闭?
c# ×3
asp.net-mvc ×2
javascript ×2
ajax ×1
asp.net-core ×1
emmet ×1
jquery ×1
mef ×1
typescript ×1
xaml ×1