小编Dar*_*hak的帖子

<label>标签内的<a>标签不触发复选框

我必须<a><label>标签内使用.因为有很多css样式只适用<a>于我们当前的系统.该<a>标签未链接到任何网页,但对于造型/徘徊.

见下面的代码:

<input type="checkbox" id="my-id">
<label for="my-id"><a href="javascript:void(0)">Some text</a></label>
Run Code Online (Sandbox Code Playgroud)

但是当点击"某些文字"时,它不会切换复选框状态.

我试过$.preventDefault()<a>标签,但没有用.

我该怎么做才能使<a>表现像标签一样?

html javascript jquery

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

文件正在被 C# 中的另一个进程使用

我正在尝试删除 C# 中的文件,但是我收到一条消息,指出该文件已从另一个进程使用。我想要做的是检查文件是否存在并关闭它。我正在使用以下函数来检查文件是否打开:

public static bool IsFileInUse(string path)
    {
        if (string.IsNullOrEmpty(path))
            throw new ArgumentException("'path' cannot be null or empty.", "path");

        try
        {
            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { }
        }
        catch (IOException)
        {
            return true;
        }

        return false;
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试在使用文件时关闭它:

bool checking = IsFileInUse(file );
File.Create(file ).Close();
if (File.Exists(file))
{
       File.Delete(file );
}
Run Code Online (Sandbox Code Playgroud)

我在 File.Create 行中遇到问题,我收到消息:

文件正被另一个进程使用。

编辑:我正在尝试使用锁定方法来删除文件。我应该删除锁定语句中的文件吗?如何正确使用lock语句?

c# asp.net filestream

2
推荐指数
1
解决办法
2万
查看次数

如何更改@Html.DisplayNameFor(model =&gt; model.name) 的显示

我做了一个 DataBase Fisrt MVC 项目,但我遇到了一些问题。这是我的一个观点的索引:例如,我想要

@Html.DisplayNameFor(model => model.name)

显示为“用户”而不是“姓名”。

我怎样才能做到这一点?

提前致谢。

@model IEnumerable<dispensario.pacientes>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.cedula)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.carnet)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.tipo_paciente)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.estado)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.cedula)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.carnet)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.tipo_paciente) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×2

asp.net ×1

asp.net-mvc ×1

filestream ×1

html ×1

javascript ×1

jquery ×1