我有一个包含2个文件的目录:
如果我做:
directoryInfo.EnumerateFiles("*.xls", SearchOption.TopDirectoryOnly)
Run Code Online (Sandbox Code Playgroud)
它返回两个文件,我只想要第一个(file1.xls).我怎样才能做到这一点?
谢谢!
有什么替代transactionScope不需要启用DTC ??
在交易中,我需要做两个操作:
我如何使用redirectAction在动作之间发送数据?
我正在使用PRG模式.我想做出类似的东西
[HttpGet]
[ActionName("Success")]
public ActionResult Success(PersonalDataViewModel model)
{
//model ko
if (model == null)
return RedirectToAction("Index", "Account");
//model OK
return View(model);
}
[HttpPost]
[ExportModelStateToTempData]
[ActionName("Success")]
public ActionResult SuccessProcess(PersonalDataViewModel model)
{
if (!ModelState.IsValid)
{
ModelState.AddModelError("", "Error");
return RedirectToAction("Index", "Account");
}
//model OK
return RedirectToAction("Success", new PersonalDataViewModel() { BadgeData = this.GetBadgeData });
}
Run Code Online (Sandbox Code Playgroud) 我有这个:
[Display(Name = "Empresa")]
public string Company{ get; set; }
Run Code Online (Sandbox Code Playgroud)
在我的aspx中我有:
<th><%: Html.LabelFor(model => model.Company)%></th>
Run Code Online (Sandbox Code Playgroud)
这会产生:
<th><label for="Company">Empresa</label></th>
Run Code Online (Sandbox Code Playgroud)
是否有任何html帮助扩展只显示没有标签的display属性,只显示纯文本?我想要的输出是这样的:
<th>Empresa</th>
Run Code Online (Sandbox Code Playgroud)
谢谢!
编辑
我按照建议尝试了DisplayFor或DisplayTextFor,但它们无效,因为它们生成:
<th>Amazon</th>
Run Code Online (Sandbox Code Playgroud)
它们返回属性的值...我想要Display属性中的名称.
我使用RouteValueDictionary将RouteValues传递给ActionLink:
如果我编码:
<%:Html.ActionLink(SharedResources.Shared_Pagination_First, Model.ActionToExecute, Model.ControllerToExecute, Model.FirstRouteValues, null)%>
Run Code Online (Sandbox Code Playgroud)
链接结果是Ok:
SearchArticles?refSearch=2&exact=False&manufacturerId=5&modelId=3485&engineId=-1&vehicleTypeId=5313&familyId=100032&page=0
Run Code Online (Sandbox Code Playgroud)
但如果我编码:
<%: Html.ActionLink(SharedResources.Shared_Pagination_First, Model.ActionToExecute, Model.ControllerToExecute, Model.FirstRouteValues, new { @title = string.Format(SharedResources.Shared_Pagination_LinkTitle, 0) })%>
Run Code Online (Sandbox Code Playgroud)
链接结果是:
SearchArticles?Count=10&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D
Run Code Online (Sandbox Code Playgroud)
有什么问题?唯一的区别是,在最后我使用的是htmlAttributes
c# ×4
asp.net-mvc ×2
html-helper ×2
.net ×1
.net-4.0 ×1
actionlink ×1
c#-4.0 ×1
html ×1
msdtc ×1
routevalues ×1
transactions ×1