Monday, January 14, 2013

Telerik Tricks: Radconfirm With Yes No Buttons

Radconfirm modal dialog box contains OK button and Cancel button to get user confirmation. There are several ways can use to change the localization settings of the radconfirm controller’s inner text. One is change localization settings using resource file. Changing localization settings using RadWindowManager is another way to change the inner text of radconfirm.

Following code snippets shows how change radconfirm localization settings using RadWindowManager


    



Following code snippet illustrate the way to change radconfirm localization using JavaScript

    Telerik.Web.UI.RadWindowUtils.Localization =   
    {    
        "OK" : "OK",  
        "Cancel" : "Cancel" 
    };


The main drawback of previously mentioned methodologies is it changes the localization settings of all radconfirm, radalerts and radwindows. To overcome that issue, need to change localization settings of specific radconfirm without effecting other radconfirm dialogs, radalerts and radwindows. Following trick can use to change the localization settings of specific radconfirm. It changes the localization settings before display the radconfirm and it change again localization settings to defaults immediate after the radconfirm get disappear.

 


Sunday, January 13, 2013

Telerik Tricks: Radconfirm with Button Click

Sometimes system requires user confirmation before submitting data or request to the server. Radconfirm is the stylish JavaScript popup which can use instead of standard confirmation. Radconfirm popup is non-blocking, that is radconfirm modal window do not block the execution thread. Because radconfirm window implemented using JavaScript and JavaScript not block the execution thread.  However server should wait until user selects one of the option shows in modal dialog box before submit the action to the server. To achieve that with radconfirm should block the button’s postback action until user confirms the action.

How block postback action of button?

Use OnClientClick action to hold button postback until user confirms. Following code snippet shows waiting mechanism of Submit button. If user clicks on the submit button it do not postback until evaluate function called “ConfirmationFunction”. If “ConfirmationFunction” return true then button continue the postback otherwise postback wont happened.






ConfirmationFunction is the JavaScript function which shows radconfirm modal dialog box and get user confirmation before submit. Following code snippet illustrate how get user confirmation and continue postback. Advantage of following mechanism is if same page contains several radpopup windows’ following mechanism does not overwrite the behaviors of other radconfirms, radalerts and radwindows.