views:

41

answers:

1

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
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%>')"
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
Thank you I will try this.