Link to home
Start Free TrialLog in
Avatar of tangteng78
tangteng78Flag for Malaysia

asked on

How to access the resource file using javascript?

Hi,
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.
Avatar of HainKurt
HainKurt
Flag of Canada image

show the code for vb first, than we can convert it to javascript
Avatar of tangteng78

ASKER

Hi,
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?
in code behibd do this

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

and on javascript use this

alert('<%=msg%>');

I hope you know how to get message from resource file...
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HainKurt,
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
if str is a public function like this

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

then you should use like

alert('<%=str(1)%>');

for example...
@HainKurt

Are you sure we can use the <% %> inside JavaScript?