我有一个用于生成报告的表格。我们正在使用RDLC报告,并且报告已加载到aspx页面中。
因此,这是将Form表单目标设置为的代码_blank,并在新标签页中打开。
@using (Html.BeginForm("AssetReports", "AssetReports", FormMethod.Post, new { target = "_blank" }))
{
<div class="row mt-15">
<div class="col-md-12 text-center">
<input type="submit" class="btn btn-primary" value="Show Report" />
</div>
</div>
}
Run Code Online (Sandbox Code Playgroud)
这是Controller动作,重定向到Report aspx页面,在该页面上处理和显示报告。
[HttpPost]
public void AssetReports(AssetReportsDTO model, AssetReportParametersDTO reportParameters)
{
SessionHandler.AssetReport = model;
SessionHandler.AssetReportParameters = reportParameters;
switch (model.SelectedReportType)
{
case AssetReportTypesEnum.ExcessiveIdleReport:
Response.Redirect("~/Reports/AssetReports/ExcessiveIdleReport/ExcessiveIdleReport.aspx");
break;
}
}
Run Code Online (Sandbox Code Playgroud)
在某些情况下,生成报告需要3.4分钟。在这段时间内,UI被阻止了,
我们希望报表在单独的线程上生成,以便用户可以在生成报表时使用UI。
MVC C#中是否可以在单独的线程中执行此操作?
我尝试使用以下内容,但随后使用了上下文和会话 NULL
Task.Factory.StartNew(() =>
{
switch (model.SelectedReportType)
{
case AssetReportTypesEnum.ExcessiveIdleReport:
Response.Redirect("~/Reports/AssetReports/ExcessiveIdleReport/ExcessiveIdleReport.aspx");
break;
}
}); …Run Code Online (Sandbox Code Playgroud) 我正在使用AngularJS,TypeScript和HTML的客户端Web应用程序,服务器端是.NET Core Web API.
我想使用ModelState和DTO实现服务器端验证.问题是我不想在窗体顶部显示所有验证错误,但我想在文本框中显示它们
首先,我将验证添加到DTO,然后检入控制器 ModelState.IsValid
public class TestDTO
{
[Required(ErrorMessage = "This field is required")]
public string TestName { get; set; }
}
public class ManyTestDTO
{
[Required(ErrorMessage = "Many Item is required")]
public string ManyItem { get; set; }
}
public class RestaurantDTO
{
public int RestaurantId { get; set; }
[Required(ErrorMessage = "This field is required")]
public string Name { get; set; }
[Required(ErrorMessage = "This field is required"), MaxLength(20), MinLength(1)]
public string Description { get; …Run Code Online (Sandbox Code Playgroud) validation asp.net-web-api angularjs typescript asp.net-core
我正在使用这个Bootstrap DateTime Picker:http://eonasdan.github.io/bootstrap-datetimepicker/
我为DateTime创建了一个名为datepicker的Custom Binder:
ko.bindingHandlers.datepicker = {
init: function(element, valueAccessor, allBindingsAccessor) {
//initialize datepicker with some optional options
var options = allBindingsAccessor().datepickerOptions || {format: 'DD/MM/YYYY HH:mm'};
$(element).datetimepicker(options);
//when a user changes the date, update the view model
ko.utils.registerEventHandler(element, "dp.change", function(event) {
var value = valueAccessor();
if (ko.isObservable(value)) {
value(event.date);
}
});
},
update: function(element, valueAccessor) {
var widget = $(element).data("datepicker");
//when the view model is updated, update the widget
if (widget) {
widget.date = ko.utils.unwrapObservable(valueAccessor());
if …Run Code Online (Sandbox Code Playgroud) 我正在动态创建jQuery中的按钮.我需要添加数据属性:
所以我在这里看到了答案:用Jquery动态创建按钮
$(document).ready(function() {
for(i = 1; i <=10; i++) {
$('<button/>', {
text: i, //set text 1 to 10
id: 'btn_'+i,
click: function () { alert('hi'); }
});
}
});
Run Code Online (Sandbox Code Playgroud)
我正在添加如下数据属性:
$(document).ready(function() {
for(i = 1; i <=10; i++) {
$('<button/>', {
text: i, //set text 1 to 10
id: 'btn_'+i,
click: function () { alert('hi'); }
}).attr('data-test', 1).attr('data-test2', 2);
}
});
Run Code Online (Sandbox Code Playgroud)
我想如果我可以做一些类似于我们添加text和id属性的方式
我有以下模特
楷模
public class Dish
{
[Required]
public Int64 ID { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Description { get; set; }
[Required]
public double Price { get; set; }
[Required]
public DateTime From { get; set; }
[Required]
public DateTime To { get; set; }
[Required]
public bool IsAvailable { get; set; }
[Required]
public string MealImage { get; set; }
[Required]
public List<Ingredients> Ingredients { get; set; }
}
public …Run Code Online (Sandbox Code Playgroud) 我是SQL新手,我遇到的问题是我在表中有很多资产的价值.我需要为该表中的每个资产获得最高速度.
我试过搜索谷歌,但我发现了MAX()SQL 的功能.
我不需要,MAX()因为这只会给我一个具有最高价值的记录.我需要每个资产的最高价:
例如
iAssetId fSpeedKPH
1 78
5 77
5 80
8 74
8 81
8 88
8 111
24 71
24 78
24 79
24 79
24 82
24 84
24 90
24 91
24 92
我突出显示了每个资产的最高行,即AssetId = 1,5,24和8
这些是我需要选择的行.
什么是最有效的方式?
我是否必须遍历由我编写的SQL返回的结果集?
编辑:
我的SQL:
DECLARE @dateMinusDay datetime = DateAdd(dd, -1, GetDate())
select vm.iAssetId, max(vm.fSpeedKPH), vm.dtUTCDateTime, ge.sGeofenceName from VehicleMonitoringLog vm
inner join Geofences ge on ge.iGeofenceId = vm.iGeofenceId
where vm.iGeofenceId != 1 AND vm.fSpeedKPH …Run Code Online (Sandbox Code Playgroud) 我需要在按钮点击按钮上方显示div以及jquery.
$("#but button").click(function(){
$("#mydiv").css("display","block");
});
<div id="but"><button type="button">Show Div!</button></div>
<div id="mydiv" style="display: none;">The div must be above button</div>
Run Code Online (Sandbox Code Playgroud)
UPDATE
我需要在按钮上方作为工具提示.
我是Knockout的新手.我正在尝试创建一个复选框列表,我按照这里的答案:
但是在尝试绑定Checkbox的CHECKED属性时出现错误.
HTML:
<ul data-bind="template: { name: 'choiceTmpl', foreach: EnquiryTypeList, templateOptions: { selections: SelectedEnquiryTypes } }"></ul>
<script id="choiceTmpl" type="text/html">
<li>
<input type="checkbox" data-bind="attr: { value: $data.Id }, checked: SelectedEnquiryTypes" />
<span data-bind="text: $data.Text"></span>
</li>
</script>
Run Code Online (Sandbox Code Playgroud)
JavaScript:
var viewModel = {
EnquiryTypeList: [new EnquiryType(1, "Text 1"), new EnquiryType(2, "Text 2")],
SelectedEnquiryTypes: ko.observableArray()
};
function EnquiryType(id, text){
Id = id,
Text = text
};
ko.applyBindings(viewModel);
Run Code Online (Sandbox Code Playgroud)
当我放1或0代替时它起作用checked: SelectedEnquiryTypes
<ul data-bind="template: { name: 'choiceTmpl', foreach: EnquiryTypeList, templateOptions: { …Run Code Online (Sandbox Code Playgroud) c# ×3
datetime ×2
jquery ×2
knockout.js ×2
.net ×1
angularjs ×1
asp.net-core ×1
asp.net-mvc ×1
automapper ×1
automapper-5 ×1
html ×1
javascript ×1
sql ×1
sql-server ×1
t-sql ×1
typescript ×1
validation ×1