resource in OnClientClick

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following works great:
OnClientClick='<%# Eval("UserName", "return confirm(\"Delete the user
{0}?\");") %>'

But I need to do this with a resource and the following does not work:
OnClientClick='<%# Eval("UserName", "<%$ Resources:Windward, Admin_Confirm
%>") %>'

How can I accomplish this?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
Hello Dave,

The problem here is that we can not use nested inline expression in aspx
template. Both <%# %> and <%$ %> are top level expression.

For your scenario, you can actually define a custom helper function for
retrieve resource value from resource file. The ASP.NET 2.0 page class
provide "GetLocalResourceObject" and "GetGlobalResourceObject" to
programmatically retrieve resource value from local or global resource
files. They can replace the <%$Resource .... %> expression. See the
following msdn reference:

#How to: Retrieve Resource Values Programmatically
http://msdn2.microsoft.com/en-us/library/ms227982.aspx

So your final code can be changed to below style:


OnClientClick='<%# Eval("UserName",
ResourceHelper("Windward","Admin_Confirm")) %>

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top