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

RadDateInput

5 Answers 159 Views
Input
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 16 May 2009, 03:52 PM
Hi All,

From a client-side javascript I calc some values and update 

RadDateInput controls from javascript: Like the example:

 

var _oSpeed = Sys.Application.findComponent('FormView1_RNTBSpeedAverage');  
var _KMTotal = parseFloat(_oKMTotal.get_value());  
var _Speed = parseFloat("0");  
 
if (_KMTotal != 0 && _Hour != 0) {  
    _Speed = (_KMTotal / _Hour);  
}  
 
_oSpeed.set_value(_Speed);   
 
 
 

 

On the website the new value is set correctly to the control (during the cliet-site javascript) but if I update/insert the record to the database (I use objectdatasources) the autmatic seted values from the controls aren't save to the database.

Any Idea why? Is there a function to update the controls after I set the set_value() function or somethign else?

Thanks a lot
Regards
Christian

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 19 May 2009, 01:37 PM
Hello Uwe,

May I ask you to provide more information in order to clarify how exactly you are trying to update the newly set value? It will be really helpful if you can send us the ASPX page and the code behind. Thus I will do all my best to find a quick solution/fix of this issue.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Christian
Top achievements
Rank 1
answered on 27 May 2009, 08:17 AM
Hi Georgi,

Sorry for the delay. I was on vacation.

There is nothign special by setting the new value. There is no code behind currently.

I calc the new value on client side an parse it to the field. After the claclualtion the radfield are optical updated with the new values.

The javascript is working correcly without any errors etc.

Here the complete javascript code:
function EditFormCalc(sender, eventArgs) { 
 
    if (sender._clientID == 'FormView1_RNTBKMDeparture') { 
        var _KMDeparture = parseFloat(eventArgs.get_newValue()); 
    } 
    else { 
        var _KMDeparture = parseFloat(Sys.Application.findComponent('FormView1_RNTBKMDeparture').get_value()); 
    } 
 
    if (sender._clientID == 'FormView1_RNTBKMArrival') { 
        var _KMArrival = parseFloat(eventArgs.get_newValue()); 
    } 
    else { 
        var _KMArrival = parseFloat(Sys.Application.findComponent('FormView1_RNTBKMArrival').get_value()); 
    } 
             
    var _oKMTotal = Sys.Application.findComponent('FormView1_RNTBKMTotal'); 
    var _oSpeed = Sys.Application.findComponent('FormView1_RNTBSpeedAverage'); 
    var _Hour = parseInt("0"); 
     
    _StartTime = new Date(); 
    _StopTime = new Date(); 
 
    _StartTime = Sys.Application.findComponent('FormView1_RDTPDateTimeDeparture').get_selectedDate(); 
    _StopTime = Sys.Application.findComponent('FormView1_RDTPDateTimeArrival').get_selectedDate(); 
 
 
    if (_StartTime != null && _StopTime != null) { 
        _Hour = Math.round((_StopTime.getTime() - _StartTime.getTime()) / 1000.); 
 
        if (_Hour != 0) { 
            _Hour = (_Hour / 3600) 
        }       
    }     
     
    if (_KMArrival >= _KMDeparture) { 
        _oKMTotal.set_value(_KMArrival - _KMDeparture); 
    } 
    else { 
        _oKMTotal.set_value(parseFloat("0")); 
    } 
 
    var _KMTotal = parseFloat(_oKMTotal.get_value()); 
    var _Speed = parseFloat("0"); 
 
    if (_KMTotal != 0 && _Hour != 0) { 
        _Speed = (_KMTotal / _Hour); 
    } 
 
    _oSpeed.set_value(_Speed);     
 

And here is one of the control:
 <telerik:RadNumericTextBox  
                                                        ID="RNTBKMTotal"  
                                                        runat="server"  
                                                        Skin="Office2007"  
                                                        Width="156px"  
                                                        Type="Number"  
                                                        CausesValidation="true" 
                                                        DataType="Double"  
                                                        ShowSpinButtons="true" 
                                                        ButtonsPosition="Right"                                                         
                                                        DbValue='<%# Bind("KMTotal") %>'
                                                    </telerik:RadNumericTextBox>    

And here is the control cause the calculation:
                                                    <telerik:RadNumericTextBox  
                                                        ID="RNTBKMArrival"  
                                                        runat="server"  
                                                        Skin="Office2007"  
                                                        Width="156px"  
                                                        Type="Number"  
                                                        CausesValidation="true" 
                                                        DataType="Double"  
                                                        ShowSpinButtons="true" 
                                                        ButtonsPosition="Right" 
                                                        ClientEvents-OnValueChanging="EditFormCalc"                                                        
                                                        DbValue='<%# Bind("KMArrival") %>'
                                                    </telerik:RadNumericTextBox>    

Thats currently all. It there someting i must do after that?

If I set all values in the form i press update or insert and if i debug I can see that all the calculated values from the javascript are not transmitted in the recordset/objectdatasource.

Thanks a lot for help
Christian


0
Georgi Krustev
Telerik team
answered on 28 May 2009, 02:38 PM
Hello Uwe Krall,

Unfortunately I could not reproduce this issue. I created a test project in my attempt to recreate the abnormality explained so far. I used the latest official build of RadControls. I've attached my sample web site project to this support thread. Please examine it and tell me if I am missing something.

All the best,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Christian
Top achievements
Rank 1
answered on 28 May 2009, 07:09 PM
Dear Georgi,

Thanks for the investigation but unfortunately we missunderstood us.

For example updates an textbox after you do something. OK But in my case I update an RadNumericTextBox which is also binded to a database field like DbValue='<%# Bind("SomeFieldFromDB") %>'>.

For example:
I have two RadNumericTextBox and the frist one has a clientevent-OnValueChanging. From this event /javascript I calculated some values depending on the input of the first RadNumericTextBox and after this I update the content/value of the second RadNumericTextBox. So you input in the first Textbox the value(int) 50. On this input you calculate something like "50 (first Textbox) * 5 = 250 in the javascript and by using set_value(newvalue) you set the value of the second TExtbos to the calculated value = 250.

So after this you click on update to sae everthing to the database. So what I expact is that the content of textbox1 and textbox2 are store to the database because both RadNumericTextBox are bind to the database object. But the textbox2 (thats value is automatic set) wouldn't be stored to the databse.

For this problem I need a solution.

Thanks again a lot for your help.
Christian
0
Georgi Krustev
Telerik team
answered on 29 May 2009, 03:44 PM
Hello Uwe,

I have modified test project in order to implement the required functionality. Please examine it and let me know if I am missing something.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Input
Asked by
Christian
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Christian
Top achievements
Rank 1
Share this question
or