Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7765867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:16:13+00:00 2026-06-01T15:16:13+00:00

I have the following Models : public class EvaluationCriteriaItem { public int ID {

  • 0

I have the following Models :

public class EvaluationCriteriaItem
{
    public int ID { get; set; }
    public string Name { get; set; }
    [Required(ErrorMessage = "*")]
    public int Score { get; set; }
    public List<EvaluationCriteriaItem> Children { get; set; }
}

public class UserPanelModel
{
    public List<SelectListItem> OrganizationsList { get; set; }
    public List<EvaluationCriteriaItem> EvaluationCriteriaList { get; set; }
}

I’ve created a TreeView from above Models with Razor :

@using AssessmentSystem.Models
@section Header{
    <link href="@Url.Content("~/Content/jquery.treeview.rtl.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.treeview.user.js")"></script>
    <style type="text/css">
        input[type="text"], input[type="password"]
        {
            width: 40px;
            margin-right: 10px;
            direction: ltr;
        }
        .treeview .hover, .filetree div.file:hover
        {
            cursor: default;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $('input[type="text"]').keydown(function (event) {
                if (event.keyCode == 46 || event.keyCode == 8 ||
                    event.keyCode == 9 || event.keyCode == 27 ||
                        (event.keyCode == 65 && event.ctrlKey === true) ||
                            (event.keyCode >= 35 && event.keyCode <= 39))
                    return;
                else if ((event.keyCode < 48 || event.keyCode > 57) &&
                    (event.keyCode < 96 || event.keyCode > 105))
                    event.preventDefault();
            });
        });
    </script>
}
@helper TreeView(List<EvaluationCriteriaItem> childrens)
    {
        for (int i=0; i<childrens.Count; i++)
        {
            if (childrens[i].Children != null && childrens[i].Children.Count > 0)
            {
    <li>
        <div class="folder">
            <div>
                <span id="@string.Format("span_{0}", childrens[i].ID)">@childrens[i].Name</span>
            </div>
        </div>
        <ul>
            @TreeView(childrens[i].Children)
        </ul>
    </li>
            }
            else
            {
    <li>
        <div class="file">
            <div>
                <span id="@string.Format("span_{0}", childrens[i].ID)">@childrens[i].Name</span>
                @Html.TextBox("ScoreFor_", childrens[i].Score == 0 ? "" : childrens[i].Score.ToString(), new { maxlength = 3 })
            </div>
        </div>
    </li>
            }
        }
}
@if (!MvcHtmlString.IsNullOrEmpty(Html.ValidationMessage("InvalidData")))
{
    <div style="width: 250px; margin: 20px auto; color: red;">
        @Html.ValidationMessage("InvalidData")
    </div>
}
@using (Html.BeginForm("SubmitScore", "UserPanel"))
{
    <table class="register-table">
        <tr>
            <td>
                Organization :
            </td>
            <td>
                @Html.DropDownListFor(x => x.OrganizationsList, Model.OrganizationsList)
            </td>
        </tr>   
    </table>
    <div style="width: 50%; margin: 0 auto;">
        <ul id="EvaluationCriteriaTreeView" class="filetree">
            @TreeView(Model.EvaluationCriteriaList)
        </ul>
        <br />
        <div style="text-align: center;">
            <input type="submit" value="Submit Score" /></div>
    </div>
}
<script type="text/javascript">
    $("#EvaluationCriteriaTreeView").treeview({
        animated: "fast"
    });
</script>

But because I’m using @Html.TextBox I can’t use server model validation.
How can I use @Html.TextBoxFor in top situation.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:16:14+00:00Added an answer on June 1, 2026 at 3:16 pm

    I would suggest using MVC Display/EditorTemplates rather than a helper in this context. With templates you get automatic collection support, and you can use a strongly typed model.

    https://web.archive.org/web/20151112171922/http://blogs.msdn.com/b/nunos/archive/2010/02/08/quick-tips-about-asp-net-mvc-ui-helpers-and-templates.aspx

    https://web.archive.org/web/20150908050041/http://blogs.msdn.com/b/nunos/archive/2010/02/08/quick-tips-about-asp-net-mvc-editor-templates.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following models public class ProfessionalEmploymentRecord { public int ID { get;
I have following ViewModel: public class Bulletin1ViewModel { [Required] public String NumberDelegations { get;
Say I have the following models: public class Item { public int Id{ get;
I have the following model: public class Tag { public int Id { get;
I have the following Model: public class DeliveryTracking { public string TrackingRef { get;
I have the following view models: public class Search { public int Id {
I have the following models: WeatherForecast: namespace TravelAssistant.Model.HelperModels.Weather public class WeatherForecast:EntityBase<int> { public IList<DayForecast>
I have the following models: public class Device { [Key] public int ID {
I have the following two models [DataContract] public class Event { [Key] public int
I have the following ViewModel: public class AllQuestionsInCategoriesViewModel { public string Category_Name { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.