[英]standard textbox doesn't get default DateTime value
I'm currently building an MVC c# application and I can't seem to find the solution for this. 我目前正在构建MVC c#应用程序,但似乎找不到解决方案。 I'm guessing it's something silly.
我猜这有点愚蠢。 It's a bit of a simplified example I'm telling right now, but it's accurate.
我现在正在讲的只是一个简化的示例,但这是准确的。 I have a strongly modelled View, @model xxx.Store and in there I show a table of items, Fruit models .
我有一个高度建模的View, @ model xxx.Store ,在其中显示了一个项目表, 水果模型 。 Now each table entry has an expire date.
现在,每个表条目都有一个到期日期。 I use JQuery's Datepicker for UI friendly datepicking, but I have trouble setting the default value in that textbox for an existing value.
我使用JQuery的Datepicker进行UI友好的日期拣选,但是我无法在该文本框中为现有值设置默认值。 I know the data gets saved, I see so in my database, but it doesn't show on the web page.
我知道数据已保存,我在数据库中看到了,但是它没有显示在网页上。
@foreach(var item in ...)
...
<input type="text" onchange="updateExpireDate(this.value, @item.LoginID);"
class="datepick" value="@item.ExpireDate.ToString()" />
...
So basically the value part, doesn't work. 因此,基本上,价值部分不起作用。 I've thought about using Html.TextboxFor(...) but that points to my central modal, the Store class, which I'm not using in that table.
我曾考虑过使用Html.TextboxFor(...),但这指向了我的中央模式Store类,我没有在该表中使用它。
Also might be important to note, the ExpireDate value is nullable. 注意,ExpireDate值可以为空,这也可能很重要。 No exceptions are thrown in Visual Studio or Chrome's Dev Tools
在Visual Studio或Chrome的开发工具中不会引发任何异常
Try Html.TextBox
尝试
Html.TextBox
@Html.TextBox("txtName", "Mairaj Ahmed ", new {class="datepick",onchange="updateExpireDate(this.value, @item.LoginID);" });
Here "Mairaj Ahmed" is value of textbox you can change it to model property. 在这里,“ Mairaj Ahmed”是文本框的值,您可以将其更改为模型属性。 And attributes will be added with new keyword separated by comma.
并且属性将添加新的关键字,并以逗号分隔。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.