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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:00:17+00:00 2026-06-04T04:00:17+00:00

I have a resource file in Asp.net and I am reading the value from

  • 0

I have a resource file in Asp.net and I am reading the value from there as follows

var val1 = '<% = Resources.Test.FirstValue%>';  //Hello
var val2 = '<% = Resources.Test.SecondValue%>';  //World          
alert(val1);
alert(val2);

It does work properly. But Suppose I want to use the String.Format function in C# inorder to make it as “Hello – World” as under

var val3 = '<%= string.Format("{0} - {1}",<% = Resources.Test.FirstValue%>,<% = Resources.Test.SecondValue%> %>';

It is throwing some compile time error

Invalid expression term '<'
Invalid expression term '='
) expected
; expected
Invalid expression term ')'

Cannot I use a server side function like that way in Javascript . However, the below works

var val3 = '<%= string.Format("{0} - {1}","Hello","World") %>';

Well I know that the problem can be solve using javascript itself. I am just curious to see how to get the String.Format function of C# work in Javascript in conjunction with Resource file values.

So, please give the correction /solution pertaining to String.Format and Resource file values only.

Thanks a lot

  • 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-04T04:00:19+00:00Added an answer on June 4, 2026 at 4:00 am

    You only need 1 set of <%= and %> for this. You’re also missing the closing ) for string.Format.

    var val3 = '<%= string.Format("{0} - {1}", Resources.Test.FirstValue, Resources.Test.SecondValue) %>';
    

    But, everything between a set of <%= and %> is C#, which doesn’t support further use of these template operators. You only need these operators again after you’ve ended the previous set:

    var val3 = '<%= Resources.Test.FirstValue %> - <%= Resources.Test.SecondValue %>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an extension method for getting a string from resource file in asp.net
I have a compiled .NET assembly with a specific resource file embedded (named 'Script.xml').
I have a specific requirement to read a resource from jar file and then
I have created a website using asp.net and I have created some resource files
I have ASP.NET MVC 3 application having resource files in english and french .
Im making a asp.net(2.0) website. I have defined two resource files in the App_GlobalResources
I am using ASP.NET resource internationalization. I have the following structure /App_LocalResources Default.aspx.resx /App_GlobalResources
I there a way in ASP.Net MVC to have a RegularExpression attribute on a
I have a web application built in asp.net, which uses resource files to support
I have used Ajax Calendar extender control (from here ) in my asp.net 3.5

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.