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

  • Home
  • SEARCH
  • 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 5847587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:44:22+00:00 2026-05-22T12:44:22+00:00

Overlooking something basic here but I am trying to set a variable and have

  • 0

Overlooking something basic here but I am trying to set a variable and have it print in several places on the page.
code behind:

public string myVariable { get {return "40"; } }

page:

<link rel="stylesheet" type="text/css" href="/css/main.css?v=<%=myVariable%>" />

output:

<link rel="stylesheet" type="text/css" href="/css/main.css?v=&lt;%=myVariable %>" />

It seems to have something to do with the quotes as this works when I take it outside of the href. I find that it works fine if I place a string in the code segement.

This works, but isn’t what I want:

<link rel="stylesheet" type="text/css" href="/css/main.css?v=<%="40"%>" />

What is the logic behind this behavior and what do I need to do to make it work? I would also settle for a more elegant method of doing 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-22T12:44:23+00:00Added an answer on May 22, 2026 at 12:44 pm

    You need to single quote the html attribute like so:

    <link rel="stylesheet" type="text/css" href='/css/main.css?v=<%=myVariable%>' />
    

    I use this all the time especially within repeaters when I want to create anchor tags

    <a href='PageToLinkTo.aspx?id=<%# DataBinder.Eval(Container.DataItem, "Id")%>'>Link Text</a>
    

    This will only work in the body of your aspx page. If you have the link tag in the head section of your aspx page then check out this question for more info: Problem in Expression tag to bind string variable

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

Sidebar

Related Questions

I am probably overlooking something really simple here but I am trying to redirect
There has to be something utterly simple I'm overlooking here, but for the life
Sorry, I think I'm being rather silly and overlooking something basic, but I'm just
I'm sure this is something really basic that I'm overlooking but compared with all
I'm new to jQueryUI and I think I am overlooking something very basic... Quick
I must be overlooking something simple. I'm setting a variable from a query result
Ok I must be overlooking something extremely simple but I am lost. Given this
Hopefully I am just overlooking something incredibly simple, if so I apologize.... I have
Still 'diving in' to Python, and want to make sure I'm not overlooking something.
I ran into an issue with something that I am probably just overlooking. I

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.