我在WinForms应用程序上有一个listview控件.
在这里,点击单独的按钮,我确实更改了一些listview项目backcolor并重新加载整个网格,因为有一些更改到数据库所以,每次点击按钮从数据库重新加载.
现在,问题是,一旦重新加载网格然后最后添加的项目滚动,所以,需要滚动所有项目并找到它,这使得最终用户很难.
有没有办法,将最后添加的项目或更新的项目自动滚动到列表视图中(我的意思是,通过编程方式,可以直接查看用户而无需手动滚动).
在常规课程中,我需要阅读以下内容HttpContext
:
控制器和操作名称
动作的属性(我可以通过HttpActionContext.ActionDescriptor.GetCustomAttributes<type>()
但这里我没有HttpActionContext
- 我只有HttpContext
)
阅读论证(例如actionContext.ActionArguments["paramName"]
,但同样 - 我只有一个HttpContext
)
它不是动作过滤器,也不是控制器类。但是,我可以访问HttpContext
.
httpcontext routedata asp.net-web-api actioncontext asp.net-web-api2
我是Automapper的新手.
我已将Nuget包 - Automapper添加到我的Manager(BLL)和DAL层.
现在,下面是相关的东西:
以下是管理器库的声明,它给了我例外:
this.dataRepository.Update(Mapper.Map<StudentMaster>(studentDTO));
Run Code Online (Sandbox Code Playgroud)
例外情况如下:
缺少类型映射配置或不支持的映射.
映射类型:
studentDTO - >
StudentMaster Admin.App.DTO.studentDTO-> Admin.App.DAL.StudentMaster
如果选择/在EF上查询,它正在工作并能够使用
.Project().To<TReturn>()
Run Code Online (Sandbox Code Playgroud)
我写了一个Autoconfiguration.cs
文件如下:
public static class AutoMapperConfiguration
{
public static void Configure()
{
ConfigureStudentMasterMaps();
}
private static void ConfigureStudentMasterMaps()
{
Mapper.CreateMap<StudentMaster, studentDTO>();
}
}
Run Code Online (Sandbox Code Playgroud)
注意:
实体 - StudentMaster
(模型)实体StudentDTO
都具有相同的属性.
请指导我如何解决此问题.
谢谢
我没有用过Form
元素.我没有使用表格,因为,我不想回发..请指导我如何做ajax调用所以,能够得到$ .ajax将viewmodel发布到控制器的动作方法?我的表格如下:
HTML:
@model comp.learn.data.Models.ProductViewModel
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
<fieldset>
<legend>ProductViewModel</legend>
<div id="CreateDiv">
<div class="editor-label">
@Html.LabelFor(model => model.ProductName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ProductName)
@Html.ValidationMessageFor(model => model.ProductName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Cost)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Cost)
@Html.ValidationMessageFor(model => model.Cost)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ProductTypeId)
</div>
<div class="editor-field">
@Html.DropDownList("ProductTypeId", "Choose item")
@Html.ValidationMessageFor(model => model.ProductTypeId)
</div>
<div class="editor-label">
@Html.LabelFor(model …
Run Code Online (Sandbox Code Playgroud) 我使用以下链接为Web api生成了大张旗鼓的文档:http : //wmpratt.com/swagger-and-asp-net-web-api-part-1/
需要将文档导出为PDF或XML文件以方便发送。
其.NET WEB API。
如何导出草率文档?
谢谢
使用承载令牌身份验证。如果响应失败,则需要返回附加字段以及以下消息:
401 UnAuthorize response
{Message: "Authorization has been denied for this request"}
Run Code Online (Sandbox Code Playgroud)
如何在 401 响应消息中包含附加字段。它将如下所示:(包括指示故障跟踪 ID 的附加字段“ID”)。
{Message: "Authorization has been denied for this request",
Id: 1}
Run Code Online (Sandbox Code Playgroud)
filter.config 如下:
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
Run Code Online (Sandbox Code Playgroud) var constraintResolver = new DefaultInlineConstraintResolver()
{
ConstraintMap =
{
["apiVersion"] = typeof( ApiVersionRouteConstraint )
}
};
config.MapHttpAttributeRoutes(constraintResolver);
config.AddApiVersioning(o => o.AssumeDefaultVersionWhenUnspecified = true);
[ApiVersion("2.05")]
[RoutePrefix("api/v{version:apiVersion}/ger")]
public class caGerController
[Route("~/api/ger/getDetail")]
[Route("getDetail")]
GetGerData
[ApiVersion("1")]
[RoutePrefix("api/v{version:apiVersion}/gerDetail")]
public class caGerDetailsController
caGerController
[Route("~/api/gerDetail/getDetail")]
[Route("getDetail")]
GetGerData
>> GetGerData
Run Code Online (Sandbox Code Playgroud)
结果:
两个 URL 都与 v1 版本 ROUTE 一起使用。
第二个 URL 既适用于 v1 也适用于没有 v1 路由的直接路由,即 [Route("~/api/gerDetail/getDetail")]
问题:第一个 URL 仅适用于 v1,它不适用于像“[Route("~/api/ger/getDetail")]”这样的直接路由,并收到如下错误:
"Error": { "Code": "ApiVersionUnspecified", "Message": "API 版本是必需的,但未指定。" }
如何解决这个问题?当我从 2.05 更改为 1.0 时,它可以工作,但 2.0 或 2.05 都不起作用。是否需要单独的文件夹?
routes asp.net-web-api asp.net-web-api-routing api-versioning
试图从 Vue 组件中分离出模板,如下所示,但它不起作用。仅引用 vue.js 文件而不是浏览。
Vue.component('my-checkbox', {
template: '#checkbox-template',
data() {
return { checked: false, title: 'Check me' }
},
methods: {
check() { this.checked = !this.checked; }
}
});
<script type="text/x-template" id="checkbox-template">
<div class="checkbox-wrapper" @click="check">
<div :class="{ checkbox: true, checked: checked }"></div>
<div class="title"></div>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
或者任何将模板与 vue 组件分离的替代方法。
是否可以像同步一样执行并在调用方法本身中获取结果。所以,我想在 $emit 完成后执行下一条语句。其如下:
Parent component has method,
doCustomValidation();
child component is as follow:
methods:
{
Save: function(){
// Can I get the response here from parent component and then, execute
doGenericValidation ?
var errorFields = this.$emit('custom-validation');
doGenericValidation(errorFields); //this is generic validations
}
Run Code Online (Sandbox Code Playgroud) 我尝试使用ajax加载局部视图.但它给了我错误Internal char error
.我调试代码然后调用操作以及调试局部视图但是,在部分视图的最后一行之后它给出了内部char错误.
以下是局部视图:
@model company.learn.data.Models.ProductViewModel
<div></div>
Run Code Online (Sandbox Code Playgroud)
行动代码如下:
public ActionResult LoadProducts()
{
RepositoryProductManager m = new Repository.ProductManager();
var p = m.RetrieveAllProducts();
var l = p.Select(o => new ProductViewModel() { Cost = o.Cost, Description = o.Description, Id = o.Id, ProductName = o.ProductName, ProductTypeName = o.ProductType.Name, ProductTypeId = o.ProductTypeId }).ToList().FirstOrDefault();
return PartialView("_LoadProducts",l);
}
Run Code Online (Sandbox Code Playgroud)
jquery ajax调用:
@section scripts
{
<script>
$.getJSON('@Url.Action("LoadProducts","ProductManagement")', null, function (data) {
alert('f');
//$('#ProductsDiv').html(data);
alert('f');
}
).error(function (e1, e2, e3) { alert(e3); }); //every time goes to alert …
Run Code Online (Sandbox Code Playgroud) c# ×3
jquery ×2
vue.js ×2
vuejs2 ×2
ajax ×1
asp.net-mvc ×1
authorize ×1
automapper-3 ×1
bearer-token ×1
chm ×1
emit ×1
getjson ×1
httpcontext ×1
javascript ×1
listview ×1
listviewitem ×1
pdf ×1
routedata ×1
routes ×1
swagger ×1
swagger-ui ×1
vb.net ×1
winforms ×1
xtemplate ×1