C# @Razor中的HtmlTextBox只读属性
只是我剃须刀页面上的C# @Razor中的HtmlTextBox只读属性,c#,asp.net-mvc,razor,C#,Asp.net Mvc,Razor,只是我剃须刀页面上的@HtmlTextBox有问题 我希望该框从另一个@HtmlTextBox填充,并且不可编辑,因为我希望将它们导出到excel文件 <table style="border:none"> <tr> <td><label class="editor-label">Start Date:</label></td> <td>@Html.TextBox("Sta
@HtmlTextBox
有问题
我希望该框从另一个@HtmlTextBox
填充,并且不可编辑,因为我希望将它们导出到excel文件
<table style="border:none">
<tr>
<td><label class="editor-label">Start Date:</label></td>
<td>@Html.TextBox("StartDate", new { @readonly = "readonly" })</td>
@*<td>@Html.TextBox("StartDate"), new { @class = "date-picker" })</td>*@
</tr>
<tr>
<td><label class="editor-label">End Date:</label></td>
<td>@Html.TextBox("EndDate", new { @readonly = "readonly" })</td>
</tr>
<tr>
<td><label class="editor-label">Supplier Company Name</label></td>
<td>@Html.TextBox("Company")</td>
</tr>
</table>
开始日期:
@TextBox(“StartDate”,new{@readonly=“readonly”})
@*@TextBox(“StartDate”),新的{@class=“date picker”})*@
结束日期:
@TextBox(“EndDate”,new{@readonly=“readonly”})
供应商公司名称
@Html.TextBox(“公司”)
这样,它在我的搜索框中就有了我不想要的“@readonly=“readonly”,并且它仍然是可编辑的。您使用了错误的重载<代码>文本框(字符串,对象)期望值作为第二个参数 您需要的是
文本框(字符串、对象、对象)
,其中第三个参数用于HTML属性:
@Html.TextBox("EndDate", "", new { @readonly = "readonly" })
您使用了错误的重载<代码>文本框(字符串,对象)期望值作为第二个参数 您需要的是
文本框(字符串、对象、对象)
,其中第三个参数用于HTML属性:
@Html.TextBox("EndDate", "", new { @readonly = "readonly" })
您必须在HTML助手中添加null参数: 现在,您的助手应该如下所示:
@Html.TextBox("EndDate",null, new { @readonly = "readonly" })
And your code will be look like this :
<table style="border:none">
<tr>
<td><label class="editor-label">Start Date:</label></td>
<td>@Html.TextBox("StartDate",null, new { @readonly = "readonly" })</td>
@*<td>@Html.TextBox("StartDate"), new { @class = "date-picker" })</td>*@
</tr>
<tr>
<td><label class="editor-label">End Date:</label></td>
<td>@Html.TextBox("EndDate", null,new { @readonly = "readonly" })</td>
</tr>
<tr>
<td><label class="editor-label">Supplier Company Name</label></td>
<td>@Html.TextBox("Company")</td>
</tr>
</table>
@Html.TextBox(“EndDate”,null,new{@readonly=“readonly”})
您的代码如下所示:
开始日期:
@TextBox(“StartDate”,null,new{@readonly=“readonly”})
@*@TextBox(“StartDate”),新的{@class=“date picker”})*@
结束日期:
@TextBox(“EndDate”,null,new{@readonly=“readonly”})
供应商公司名称
@Html.TextBox(“公司”)
干杯 您必须在HTML助手中添加null参数: 现在,您的助手应该如下所示:
@Html.TextBox("EndDate",null, new { @readonly = "readonly" })
And your code will be look like this :
<table style="border:none">
<tr>
<td><label class="editor-label">Start Date:</label></td>
<td>@Html.TextBox("StartDate",null, new { @readonly = "readonly" })</td>
@*<td>@Html.TextBox("StartDate"), new { @class = "date-picker" })</td>*@
</tr>
<tr>
<td><label class="editor-label">End Date:</label></td>
<td>@Html.TextBox("EndDate", null,new { @readonly = "readonly" })</td>
</tr>
<tr>
<td><label class="editor-label">Supplier Company Name</label></td>
<td>@Html.TextBox("Company")</td>
</tr>
</table>
@Html.TextBox(“EndDate”,null,new{@readonly=“readonly”})
您的代码如下所示:
开始日期:
@TextBox(“StartDate”,null,new{@readonly=“readonly”})
@*@TextBox(“StartDate”),新的{@class=“date picker”})*@
结束日期:
@TextBox(“EndDate”,null,new{@readonly=“readonly”})
供应商公司名称
@Html.TextBox(“公司”)
干杯