I would like to show Confirm alert on button click, but confirm message I would like to show from a global resource file? How do I do this? Something like this. OnClientClick="return confirm('<%$ Resources:MfnWeb, ConfirmCloseAccount%>')"
A:
You can simply set OnClientClick as you suggested in the codebehind file, eg. in PageLoad event, or write a element inside page head with a function 'customized' for each page:
<script type="text/javascript">
function myResource()
{
return '<%$ Resources:MfnWeb, ConfirmCloseAccount %>';
}
</script>
Then call this function in any javascript code you want.
Diego Pereyra
2010-06-10 12:05:32
I need to use only on Button ClientClick is there a way I can directly bind it in a Confirm alert? return confirm('<%$ Resources:MfnWeb, ConfirmCloseAccount%>')"
2010-06-10 12:11:25
The problem is that you cannot use <%$ %> inside an attribute. What you can do is to set the funtcion on the codebehind file, or call 'return confirm(myResource())', or make a function that shows the confirmation.
Diego Pereyra
2010-06-10 15:30:36
Thank you I will try this.
2010-06-10 17:22:13