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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:24:06+00:00 2026-05-13T15:24:06+00:00

<p> <label for=Tags>Tags:</label> <% String tagsText = ; foreach (Tag item in Model.Tags) {

  • 0
<p>
    <label for="Tags">Tags:</label>
    <% String tagsText = "";
       foreach (Tag item in Model.Tags)
       {
           tagsText += item.Name + " ";
       }
    %>
    <%= Html.TextBox("Tags", tagsText.Trim()) %>
    <%= Html.ValidationMessage("Tags", "*") %>
</p>

Obviously this code is not perfect, and I admit that. But how would you improve it? It seems a little sloppy to me.

  • 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-05-13T15:24:07+00:00Added an answer on May 13, 2026 at 3:24 pm

    Not a whole lot cleaner but this has the added benefit of not adding a trailing space at the end of the string.

    <p>
        <label for="Tags">Tags:</label>
        <% string tagsText = string.join(" ", (from t in Model.Tags 
                                               select t.Name).ToArray<string>()); %>
        <%= Html.TextBox("Tags", tagsText) %>
        <%= Html.ValidationMessage("Tags", "*") %>
    </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I store labels/tags in my database (mockup below): labels: text:string //name of the label/tag
I want to verify that the HTML tags present in a source string are
I'm following this tutorial to create tags for a model (in my case the
in this variable: $this->item->text I have this string: <!-- JoomlaWorks Disqus Comment System for
I have a Post and a Tag model: class Post < ActiveRecord::Base has_and_belongs_to_many :tags
I want to hide the label tags in my form input tags of my
I am trying to hide all the label tags on my jQuery Mobile site
The Label, Button, TextArea, and TextBox (abbreviated LBTT from now on) are capable of
The error label displays till the width of the table. As this: alt text
Original I want to parse a string of html code and add newlines after

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.