How to access the resource file using javascript?

I have some message that i want to use as popup in javascript from my resource file (globalisation purposes). I have no problem to do that in VB and in the web control.

Please help.
Who is Participating?
HainKurtSr. System AnalystCommented:
show the code for vb first, than we can convert it to javascript
tangteng78Author Commented:
I have a javascript alert

alert('this should come from resource file')

In resource.resx
name = strAlert
value = "this should come from resource file"

How do i use the javascript (in this case the alert) to call the strAlert in the resource file?
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

HainKurtSr. System AnalystCommented:
in code behibd do this

public msg as string
msg = get value from resource file and set it...

and on javascript use this


I hope you know how to get message from resource file...
tangteng78Author Commented:
this is the error i get. Please advise.

Server Error in '/Muncch Rev4.0' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30455: Argument not specified for parameter 'Number' of 'Public Function Str(Number As Object) As String'.

Source Error:

Line 10:         //Validate web controls other than those supported by validator (eg: checkboxes)
Line 11:         function validate_checkbox() {
Line 12:          alert('<%=str%>');
Line 13:         }
Line 14:  </script>    

Source File: C:\Users\ethan\Documents\Visual Studio 2008\WebSites\Muncch Rev4.0\localization.aspx    Line: 12
HainKurtSr. System AnalystCommented:
if str is a public function like this

'Public Function Str(Number As Object) As String'

then you should use like


for example...

Are you sure we can use the <% %> inside JavaScript?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.