小编Ped*_*dre的帖子

在EnumerateFiles中配置SearchPattern

我有一个包含2个文件的目录:

  • file1.xls
  • file2.xlsx

如果我做:

directoryInfo.EnumerateFiles("*.xls", SearchOption.TopDirectoryOnly)
Run Code Online (Sandbox Code Playgroud)

它返回两个文件,我只想要第一个(file1.xls).我怎样才能做到这一点?

谢谢!

.net c# directoryinfo c#-4.0

7
推荐指数
1
解决办法
4324
查看次数

没有DTC的TransactionScope替代方案

有什么替代transactionScope不需要启用DTC ??

在交易中,我需要做两个操作:

  1. 创建一个用户(使用成员资格--sql成员资格提供者)
  2. 做一次插入操作.

c# msdtc transactions .net-4.0 transactionscope

6
推荐指数
1
解决办法
9257
查看次数

使用redirectAction和prg模式在操作之间发送数据

我如何使用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)

asp.net-mvc-3

4
推荐指数
1
解决办法
9889
查看次数

Html帮助器显示没有标签的显示名称属性

我有这个:

[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属性中的名称.

html c# asp.net-mvc html-helper

4
推荐指数
1
解决办法
6716
查看次数

RouteValueDictionary和htmlAttributes之间是否存在冲突?

我使用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# asp.net-mvc html-helper actionlink routevalues

4
推荐指数
1
解决办法
1656
查看次数