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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:33:28+00:00 2026-05-26T03:33:28+00:00

I have an asp.net website, but I need to pass stuff to javascript to

  • 0

I have an asp.net website, but I need to pass stuff to javascript to do stuff there. At the moment, I am doing things like this:

<script type="text/javascript">
    var userHasMicrositePhoto = '<%=hasMicrositePhoto%>';
</script>

But I’ve been told that putting lots of script tags in like this is bad, and also its annoying to have to keep writing Properties in my code behind.

What is a better way to do this?

  • 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-26T03:33:29+00:00Added an answer on May 26, 2026 at 3:33 am

    This is pretty much the ideal way to go IMO. If you have a lot of stuff like this, try putting it all in one <script>block. You could also use an array to reduce the code overhead, or have asp.net output a JSON encoded array with all the needed properties in it.

    Depending on your architecture, you could consider fetching those properties through a separate Ajax request which would make the page body a bit cleaner, but it would be an extra request that can’t be cached, so I would use this only in very extreme cases.

    The same applies to embedding a separate <script src=....> it looks nicer in the generated markup, but needs another request to the server.

    • 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 website that uses forms authentication. There are a few things
I am using ASP.NET C# Website I have a JavaScript function. In this function,
Hi, I have built a ASP.NET MVC website that uses Membership, this works fine.
I have an asp.net website which contains a few pages that I'd like to
I have an ASP.NET website and from one of the web pages I need
I have an ASP.NET website hosted on GoDaddy. I need to redirect (301) every
I have an asp.net mvc3 website, I need to update the database periodically, for
This is an ASP.NET MVC website. Following domain driven design, we have a service
I have a ASP.Net website that is failing on AJAX postbacks (both with ASP.Net
I have an ASP.NET website and when I press F5 it automatically attaches to

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.