Reputation: 11
I use Kendo UI MVC4 in my project. My ProductItem.cshtml in View is :
<form class="k-content" id="ticketsForm">
<ul class="edit-form">
<li>
<label for="Name" class="required">Name:</label>
@Html.TextBox("Name", ViewData["Name"] ?? string.Empty)
</li>
<li>
<label for="Price">Price:</label> @Html.TextBox("Price", ViewData["Price"] ?? string.Empty)
</li>
<li>
<label for="Quantity">Quantity:</label> @Html.TextBox("Quantity", ViewData["Quantity"] ?? string.Empty)
</li>
<li>
<label for="ExpiredDate">ExpiredDate:</label>
@(Html.Kendo().DatePicker()
.Name("ExpiredDate")
.Value("08/06/2015")
.HtmlAttributes(new { style = "width:150px" })
)
</li>
</ul>
</form>
I want to validate textbox but I don't know how. Can someone helps me.
Thank you
Upvotes: 0
Views: 1165
Reputation: 1414
I would suggest re-constructing your objects. Rather than adding the values in ViewData, you can consider using Models and add validators on the models.
Please refer to the post
Upvotes: 1