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 8129099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:09:39+00:00 2026-06-06T08:09:39+00:00

I have a problem, I described it in this place How create UIHit YesNoNull?

  • 0

I have a problem, I described it in this place How create UIHit YesNoNull?

I solved this problem by creating a helper:

public static MvcHtmlString YesNoNull(this HtmlHelper helper, string name)
{
    return YesNoNull(helper, name, false);
}

public static MvcHtmlString YesNoNull(this HtmlHelper helper, string name, bool selected)
{
    var builder = new StringBuilder(500);
    builder.Append(string.Format("<input id='checkbox_{0}' type='checkbox' />Есть", name));
    builder.Append("<script type=\"text/javascript\">$(function () {");
    builder.Append(string.Format("$('#checkbox_{0}').click(function () {{", name));
    builder.Append(@"var checked = $(this).attr('checked');if (checked != undefined) {");
    builder.Append(string.Format("$('#{0}').show();}}", name));
    builder.Append(string.Format("else {{$('#{0}').hide();}}  }});", name));
    builder.Append(string.Format("$('#checkbox_{0}').attr('checked', {1});", name, selected.ToString().ToLower())); 
    builder.Append(string.Format("var checked = $('#checkbox_{0}').attr('checked');if (checked != undefined){{ $('#{0}').show(); }}else{{$('#{0}').hide();}}", name));
    builder.Append("})</script>");




    return new MvcHtmlString(builder.ToString());
}

I use it so:

@Html.YesNoNull("VenueUrl", false)
@Html.EditorFor(model => model.VenueUrl)

is it possible to do the same thing but without the use of the helper and the only one design:

@Html.EditorFor(model => model.VenueUrl)
  • 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-06T08:09:47+00:00Added an answer on June 6, 2026 at 8:09 am

    I believe you could create a template in ~/Views/Shared/EditorTemplates/ called YesNoNull.cshtml and add the markup there.

    Whenever you call @Html.EditorForin your views, it looks in ~/Views/Shared/EditorTemplates or ~/Views/Shared/DisplayTemplates/ for a template that matches the models type.

    So, for strings it would take String.cshtml, for DateTime it would take DateTime.cshtml, and so on. If you define a UIHint attribute it should take whatever you called the UIHint as template

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

Sidebar

Related Questions

I have the same problem described here on the e-office blog , but in
I have the same problem as described in ( Last record of Join table
I have the same question problem as described here How to purge a cached
I have a problem, which is not easily described. I'm writing a web application
I have a navigation problem. I want to create the following navigation structure: Start
I have a problem with forwarding to a .jsp page. Let me describe my
A bit of a complex problem to describe here: I would like to have
I have no idea how to describe my problem. It is the simplest way
Best to use an example to describe the problem. Lets say I have a
I have a question which is described below: What problems would arise for testing

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.