tangteng78
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.
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.
show the code for vb first, than we can convert it to javascript
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?
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...
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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\V isual Studio 2008\WebSites\Muncch Rev4.0\localization.aspx Line: 12
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\V
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...
'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?
Are you sure we can use the <% %> inside JavaScript?