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

[Solved] How manipulate "save" client side event, creating an appointment?

1 Answer 138 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Daniel Cuba
Top achievements
Rank 1
Daniel Cuba asked on 04 Mar 2010, 09:23 PM
Hi.

I need to do something in client side when the user click the save button (the same in the "update") of a appointment create (or edit). I don´t want to use an  Advanced Templates because I only need this. 

I try with the "OnClientAppointmentInserting" but this fire when I click the appointment and I want to do something just before to send the postback after the user set values in the form of creating. 

I´m using: StartEditingInAdvancedForm="true" if this can help to understand.

Anybody know how to "take" this event.

Thanks

1 Answer, 1 is accepted

Sort by
0
Daniel Cuba
Top achievements
Rank 1
answered on 09 Mar 2010, 10:46 PM
Hi.

Nobody answer to me, but I solve my problem. Maybe someday this help to anybody.

I did the fallowing:

1- I took the "save" button ID, with the inspector of Firebug in Firefox. 

2- Like I saw with the firebug it was a link button, that`s why I change the href property and I redirect the call to my own validation function. But before, I save the original href.

3. In my function I did my validation and finally I call the original href: this save the appointment.

I hope this help to anybody. 

This is the code:

function ClientFormCreated(sender, eventArgs) 
{  
   var SaveUpdateButton = document.getElementById("<%= this.ClientID %>_schdlrModulesList_Form_InsertButton"); 
                
//The button ID in Update and Create are diferents, I have to see wich case is...                 
if(SaveUpdateButton == null
                    SaveUpdateButton = document.getElementById("<%= this.ClientID %>_schdlrModulesList_Form_UpdateButton"); 
                 
refer = SaveUpdateButton.href; 
SaveUpdateButton.href = "javascript:OnClientAppointmentInsert(refer)"
 
function OnClientAppointmentInsert(referParam) 
        {    
            var guardar = true;             
                         
            var templateValue = ($("#<%= this.ClientID %>_schdlrModulesList_Form_ResTemplate option:selected").text()); 
            var moduleValue = ($("#<%= this.ClientID %>_schdlrModulesList_Form_ResModule option:selected").text()); 
             
             
            var otra = referParam.replaceAll('\"','\''); 
            otra = otra.replaceAll("%20"" ");      
 
            var errorPanel = document.getElementById("<%= this.ClientID %>_pnlErrorMessage"); 
  
            var errorMsg = document.getElementById("<%= this.ClientID %>_lblErrorMessage"); 
             
            errorMsg.innerHTML = ""
             
//Here I did my validations 
            if(templateValue == "-"){ 
                errorMsg.innerHTML = "Debe seleccionar un Template.";                                           
                errorPanel.style.display = ''
                guardar = false;                     
            } 
             
            if(moduleValue == "-"){ 
                if(guardar == false
                    errorMsg.appendChild(document.createElement("br")); 
                 
                errorMsg.innerHTML += "Debe seleccionar un Modulo.";                                           
                  
                errorPanel.style.display = ''
                 
                guardar = false
            } 
             //If my validations are good I call the save function                            
            if(guardar){                 
                errorPanel.style.display = 'none';               
                eval_global(otra);            
            }     
        } 
         
        function eval_global(codetoeval) { 
            if (window.execScript)  //for IE 
                window.execScript(codetoeval);  
            else        //for the other browsers 
                eval(codetoeval); 
        } 

Tags
Scheduler
Asked by
Daniel Cuba
Top achievements
Rank 1
Answers by
Daniel Cuba
Top achievements
Rank 1
Share this question
or