This is a migrated thread and some comments may be shown as answers.

Altering Confirm template

1 Answer 80 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 15 Nov 2010, 11:58 PM
I want to handle when the user pushes the enter key.

I have got the following code

<ConfirmTemplate >
                <div class="rwDialogPopup radconfirm">   
                    <div class="rwDialogText">
                    {1}    
                    </div>      
                    <div>
                    <a onclick="$find('{0}').close(true);"  class="rwPopupButton" href="javascript:void(0);" ><span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[Yes]##</span></span></a>
                    <a onclick="$find('{0}').close(false);" class="rwPopupButton"  href="javascript:void(0);"><span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[No]##</span></span></a>
                    </div>
                </div>
                    <script language="javascript" type="text/javascript">
            function pageLoad() {
                document.onkeypress = KeyPressHappened;
            }
            function KeyPressHappened(e) {
                if (!$find('{0}')) return;
                if (!e) e = window.event;
                if ((e.keyCode >= 0) && (e.keyCode <= 127))
                    $find('{0}').close(true);
            }
            
            pageLoad();//Wrong place to call this! but where do i put it?
 
    </script>
            </ConfirmTemplate>

Where i call the function pageLoad(); its currently being called when the entire page loads, how do i set it up so that it will be called when the window loads so that it only tracks key events for the radwindow and not the entire page that the window is declared in?

1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 18 Nov 2010, 11:11 AM
Hi Mark,

In such scenario, I would suggest a slightly different approach - to put the JS code in the content of the page (not in the template as there is no event fired in it when the template is shown). Please find attached a small sample based on your code that shows this approach.

Kind regards,
Georgi Tunev
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Window
Asked by
Mark
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or