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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:36:57+00:00 2026-06-07T05:36:57+00:00

I have a javascript in my page which requires a string list in this

  • 0

I have a javascript in my page which requires a string list in this format:

var availableTags = [
        "ActionScript",
        "AppleScript",
        "Asp",
        "BASIC",
        "C",
        "C++",
        "Clojure",
        "COBOL",
        "ColdFusion",
        "Erlang",
        "Fortran",
        "Groovy",
        "Haskell",
        "Java",
        "JavaScript",
        "Lisp",
        "Perl",
        "PHP",
        "Python",
        "Ruby",
        "Scala",
        "Scheme"
    ];

My model in the view contains a list of string named blogtags.
How do I add the list in the viewmodel to the javascript.

Thanks
Arnab

  • 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-07T05:36:58+00:00Added an answer on June 7, 2026 at 5:36 am

    I would add a string type to hold a comma seperated tags to my viewmodel

    public class BlogPostViewModel
    {
      //Other properties    
      public string Tags { set;get;}    
    }
    

    In my controll, I will set the value of this from the List of string

    public ActionResult View(int id)
    {
      var vm=new BlogPostViewModel();
    
      List<string> tagList=new List<string>(); 
      tagList.Add("PERL");   //get from your DB instead of hardcoding
      tagList.Add("RUBY");
    
      StringBuilder strTags = new StringBuilder();
      foreach (var item in tagList)
      {
         strTags.Append("\""+item+"\",");
      }
      vm.Tags=strTags.ToString();
      vm.Tags= vm.Tags.TrimEnd(','); //remove last ,
      return View(vm);
    }
    

    And in the View

    $(function () {    
      var items=[@Html.Raw(Model.Tags)]
      alert(items);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript page which checks an email and username, this works fine
I have an Asp.net page which requires certain sections to be partially updated automatically
I have the following javascript in my page which does not seem to be
I have my JavaScript alert on a page which alerts user with my custom
I have a JavaScript code which links to survey poll page. When I am
I have a one page web application, which means alot of javascript. External scripts
Often I will have a JavaScript file that I want to use which requires
I have a JavaScript based page where a grid displays all the data for
We have a javascript function we use to track page stats internally. However, the
I have multiple javascript functions in my html page. One of them, by far

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.