RadWindow confirm dialog localization with resource files.

4 posts, 0 answers
  1. Eric Routhier
    Eric Routhier avatar
    8 posts
    Member since:
    Feb 2010

    Posted 23 Jul 2010 Link to this post

    Im currently using this example in one of my projects :
    Confirm dialog example

    When I want to use resources files to localize my application, i normally use a tag like this to set the text :
    Snippet
    Text="<%$ Code: ResourceFile.Some_TranslatedText_DependingOnCulture %>"

    Do you have a suggestion on how I can use the same technique to have to localized version of the prompt text and title text ? The sample below is obviously not working ...

    Snippet
    OnClientClick="return blockConfirm(" + <%$ Code: 
    ResourceFile
    .TranslatedPrompt %> + ", event, 330, 100, '', " + <%$ Code: 
    ResourceFile
    .
    TranslatedTitle 
     %> + ");"


    Thank you !
  2. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 29 Jul 2010 Link to this post

    Hello Eric Routhier,

    You can store the resource values in custom attributes and use them in onclick, e.g.
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function ShowConfirm(text, title)
            {
                radconfirm(text, confirmCallBackFn, 330, 100, null, title);
            }
            function confirmCallBackFn(arg)
            {
                radalert("radconfirm returned the following result: " + arg , null, null, "Result");
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
        <div>
         <input type="button" value="ShowConfirm" 
            customText="<%$ Resources:ResourceFile, Text%>"
            customTitle="<%$ Resources:ResourceFile, Title%>"
            onclick="ShowConfirm(this.customText, this.customTitle)" runat="server" />
        </div>
        </form>
    </body>
    </html>
    Hope this helps.

    Regards,
    Petio Petkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Afework
    Afework avatar
    3 posts
    Member since:
    Jul 2011

    Posted 06 Dec 2011 Link to this post

    Using custom attributes works well in IE(Internet explorer) but not in Firefox, Chorme and other web browsers.
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4529 posts

    Posted 07 Dec 2011 Link to this post

    Hi Afework,

    Please make sure you get the attributes correctly and pass them to the radconfirm properly. Using custom attributes is considered general knowledge and is actually not related to the RadControls - the RadConfirm will display the text you pass. If you do not provide a valid string you will naturally get a JavaScrtip error.

    I tested this scenario and I can suggest a safer way of getting attributes:
    <input id="Button1" type="button" value="ShowConfirm" 
       customText="<%$ Resources:ResourceFile, Text%>" 
       customTitle="<%$ Resources:ResourceFile, Title%>" 
       onclick="ShowConfirm(this.getAttribute('customText'), this.getAttribute('customTitle'))" runat="server" />

    I am also attaching my test page that seems to be working fine: http://screencast.com/t/9R4lkDSAB. Please compare it with yours and use this as base for your further development.

    Regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top