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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:03:01+00:00 2026-06-05T23:03:01+00:00

In the asp.net mvc 3 application I have two views which have the same

  • 0

In the asp.net mvc 3 application I have two views which have the same set of javascript functions. Javascript is identical so I want to reorganize this code and extract all the javascript code into .js file in order to include it in both chtml files.

The problem is that one of the javascript functions uses C# code in order to get some data from model. How can I insert C# code into the javascript(.js) file or how can I extract all this code into a separate chtml file and include it in both of the previous?

  • 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-05T23:03:04+00:00Added an answer on June 5, 2026 at 11:03 pm

    You can’t natively, or at least you shouldn’t. Both for maintenance and performance reason.

    You should instead redesign your javascript to have parameterized methods, and initialize the custom value from your views.

    Think like jQuery. A lot of plugins are available, standardized, but they are initialized with specific value on pages that are consuming them.

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

Sidebar

Related Questions

I have an ASP.NET MVC application, and the visitors can select from two languages
I have an ASP.Net MVC application with a model which is several layers deep
In my ASP.NET MVC 3 application i have two types of users - regular
I have two projects in the same solution. One is an ASP.NET MVC 2
I have two ASP.NET MVC web applications. One of them logs unhandled exceptions to
In my ASP .NET MVC application i have a link that refreshes the preview
I have one question; In my ASP.NET MVC web application have to do certain
In an ASP.NET MVC application where I have the following model.. public class EventViewModel
I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This
I have an Asp.Net MVC application that works in the vs.net development web server.

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.