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

TimeView.Enabled doesn't work!!

22 Answers 165 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Malek
Top achievements
Rank 1
Malek asked on 14 Jun 2009, 12:41 AM
Hi
I am using "Timeview.Enabled" to disable the TimePicker in server side  code, and it was working in previous releases...
but now it doesn't work!!!
Thank you

22 Answers, 1 is accepted

Sort by
0
Johny
Top achievements
Rank 1
answered on 14 Jun 2009, 03:29 PM
Hi Malek,
I tried
Picker.TimeView.Enabled = false
and it works.
However it disables the embedded TimeView object only.
If you want to disable the Picker itself, you can try
Picker.Enabled=false

Hope this helps.
0
Malek
Top achievements
Rank 1
answered on 15 Jun 2009, 06:21 PM
Hi Martin
thank you for your reply ...

but   Picker.TimeView.Enabled = false doesn't work
Im using picker.set_enabled(false) to do the same in javaScript and it works !!!

Note: both of them were working in previous releases and I didn't make any change to my code!!!

thank you
0
Johny
Top achievements
Rank 1
answered on 17 Jun 2009, 08:22 AM
Hi Malek,

Actually you are correct about that Picker.TiemView.Enabled=false does not disable the time view.
It only changes the TimeView style to disabled but still lets you pick a time value.
But what i couldn't understand is what actually do you intend to do?
Do you want to disable the embedded TimeView or the entire Picker control?
And where do you want this action to take place - on the server or on the client?
Your initial query asks for server code, but i see that you accomplished picker.set_enabled(false) on the client,
which should have resulted in disabling the entire picker control.
Can you please clear your intention about this scenario?

Thank you
0
Malek
Top achievements
Rank 1
answered on 17 Jun 2009, 12:26 PM
Hi Martin

Actually what I need is to disable the entire control.not the embedded TimeView ...
and I need to do that in both server side and client side.

 I know that I can do that in server code by using Picker.Enabled=false, but in the client there is no function to use.
for this reason I make the TimeView disabled instead, and as I told you that was working with previous releases.

I want to tell you that picker.set_enabled(false) client side function disables the TimeView not the entire control

thank you
0
Johny
Top achievements
Rank 1
answered on 17 Jun 2009, 02:23 PM
Hello Malek,

Can you please run the code bellow and tell me if it works for your scenario on the client side?
Used this way it disables the entire control.
 

 

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">

            function DisableControl() {

                var picker = $find("<%=RadDateTimePicker1.ClientID %>")

                picker.set_enabled(false)

            }

        </script>

</telerik:RadScriptBlock>

 

<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server">

        <Calendar>

            <ClientEvents OnLoad="DisableControl" />

        </Calendar>

</telerik:RadDateTimePicker>


Regards,
Martin

0
Malek
Top achievements
Rank 1
answered on 17 Jun 2009, 03:01 PM
Hi Martin
First, Im using RadTimePicker not RadDateTimePicker (I don't know if there is any difference in our case??).

and I am using the same way that you used in the code example(with TimePicker) but it disables the embedded TimeView only!!
and this is my scenario ...

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
 
        <script language="javascript" type="text/javascript"
             
            var timePkr1ID = "<%= timePkr1.ClientID %>"
            function myJsFunction() {               
                timePkr1 = $find(timePkr1ID); 
                timePkr1.set_enabled(false); 
            } 
         </script> 
 
</telerik:RadCodeBlock> 
     
        <asp:CheckBox ID="CheckBox1" onclick="myJsFunction()" runat="server" /> 
         
        <telerik:RadTimePicker ID="timePkr1" runat="server"
                </telerik:RadTimePicker> 


thank you
0
Johny
Top achievements
Rank 1
answered on 17 Jun 2009, 08:12 PM
Hi Malek,

I spent some more time in this issue and found that you can accomplish your goal in two ways.
1.Using MS AJAX UpdatePanel:
<asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager>  
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">  
        <ContentTemplate>  
            <telerik:RadTimePicker ID="RadTimePicker1" runat="server">  
            </telerik:RadTimePicker>  
            <asp:CheckBox ID="checkBox1" OnCheckedChanged="checkBox1_CheckedChanged" AutoPostBack="true" runat="server">
            </asp:CheckBox>  
        </ContentTemplate>  
    </asp:UpdatePanel>  
 
        
 
 
    void checkBox1_CheckedChanged(object sender, EventArgs e)  
    {  
        RadTimePicker1.Enabled = ((CheckBox)checkBox1).Checked;  
    }  
 
2.Using client-side code only:
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">  
        <script type="text/javascript">  
            function myJsFunction() {  
                var picker = $find("<%= RadTimePicker1.ClientID%>")  
                picker.set_enabled(!picker.get_enabled())  
            }  
        </script>  
</telerik:RadScriptBlock>  
 
<asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager>  
            <telerik:RadTimePicker ID="RadTimePicker1" runat="server">  
            </telerik:RadTimePicker>  
            <asp:CheckBox ID="checkBox1" onclick="javascript:myJsFunction()" runat="server">  
            </asp:CheckBox> 

Please let me know if this works for you.

Regards,
Martin
0
Malek
Top achievements
Rank 1
answered on 17 Jun 2009, 09:51 PM
Hi Martin

Thank you for your help and time.

but I think that the problem didn't solved!!!
I can't use the first scenario, so Im using the second one...
but as I told you Im in need to use both client and server code...
please notice that " picker.Enabled = false; " and " picker.set_enabled(false); " don't do the same thing!! the first one disabled the entire timePicker, whereas the second disabled the embedded TimeView.

and the following is exactly what I mean:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
  
        <script language="javascript" type="text/javascript">  
              
            var timePkr1ID = "<%= timePkr1.ClientID %>";  
            function myJsFunction() {                
                timePkr1 = $find(timePkr1ID);  
                timePkr1.set_enabled(true);  
            }  
         </script>  
  
</telerik:RadCodeBlock>  
      
        <asp:CheckBox ID="CheckBox1" onclick="myJsFunction()" runat="server" />  
          
        <telerik:RadTimePicker ID="timePkr1" runat="server">  
        </telerik:RadTimePicker>  
 
 
 
protected void Page_Load(object sender, EventArgs  
     timePkr1.Enabled = false;//got from database 


thank you
Malek

0
Johny
Top achievements
Rank 1
answered on 18 Jun 2009, 07:31 AM
Hi Malek,

In your code can you please replace:

protected void Page_Load(object sender, EventArgs e)  
    {  
        timePkr1.Enabled=false;  
    } 

with this code:

protected void Page_Load(object sender, EventArgs e)  
    {  
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "myScript",   
            "Sys.Application.add_load(function() { $find('" + timePkr1.ClientID +   
            "').set_enabled(false); });"true);  
    } 

Let me know if it works the way you want.

Regards,
Martin
0
Malek
Top achievements
Rank 1
answered on 18 Jun 2009, 07:53 AM
Hi Martin,
I think that the code you have posted is working good in the simple scenario that I've posted ...
but actually I have more complicated scenarios in my project ...
I have a lot of TimePickers which are created dynamicly in data bounded controles like repeater, so I think that I need to use server code to do that ...
and if I use your last solution, the managing of my code will be too difficult.

and finally I want to ask why Picker.TimeView.Enabled = false doesn't work as in previous releases?? I was using it and it was good.

thank you Martin
Malek
0
Johny
Top achievements
Rank 1
answered on 18 Jun 2009, 02:23 PM
Hi Malek,

Unfortunatelly i have no clue why disbling the embedded timeview on the server does not work properly.
I haven't used previous versions of the Rad controls so i can not make any comparison.
One option of receiving the result you want is to disable the embedded TimePopupButton control.
I think this scenario is the closest to the one you aim.

Regards,
Martin
0
Daniel
Telerik team
answered on 19 Jun 2009, 04:23 PM
Hello Malek,

Which is the RadControls version you are referring to? I would like to clarify that the TimeView's Enabled property is inherited from the WebControl class and therefore its behavior is handled by the framework, not by our code.

Best regards,
Daniel
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
Malek
Top achievements
Rank 1
answered on 20 Jun 2009, 12:34 PM
Hi There,

I'm using this version Q1 2009 SP2 (version 2009.1.527) of Rad Controls (I think it is the latest one??)

I don't know what is the wrong????
 but as I posted earlier my code was working with older versions and I didn't make any change to my code!!

Thank you
Malek
0
Daniel
Telerik team
answered on 22 Jun 2009, 07:06 AM
Hello Malek,

Could you please answer my previous question? Which is that "older" version you mentioned?

Regards,
Daniel
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
ataya
Top achievements
Rank 1
answered on 23 Jun 2009, 10:30 PM
Hello Daniel

I was using Q1 2009 (version 2009.1.311)  version, but I think that it doesn't the issue!!

the issue is why picker.TimeView.Enabled doesn't work ... don't you think so?

Thank you
Malek
0
Daniel
Telerik team
answered on 26 Jun 2009, 04:04 PM
Hello Malek,

Please excuse me if I wasn't clear enough. We never had such functionality implemented in the RadTimePicker. As I tried to explain above, the observed behavior is handled by the framework.

Based on the provided information, I tried to disable the nested TimeView using the 2009.1.311 version -  I noticed that the "disabled" style was applied to the table. However (as expected), I also noticed that the events are still attached and the normal functionality of the TimeView is not affected at all.

I hope my explanation is helpful. Let me know if you need more details.

Regards,
Daniel
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
ataya
Top achievements
Rank 1
answered on 26 Jun 2009, 04:22 PM
Hi Daniel,
Thank you for your explanation ...
 
Now I'm using Q1 2009 SP2 (version 2009.1.527)   
and as I told you using picker.TimeView = false;(server code)  to make the embedded timeView disabled but it is still enabled...
and Im using picker.set_enable(false) (client code) to do the same, but when a page postback happens the embedded timeView automatically returns to enabled case.

I hope you can help me in this issue

thank you
Malek

0
Daniel
Telerik team
answered on 02 Jul 2009, 11:07 AM
Hello Malek,

The enabled/disabled state is not persisted on purpose to avoid issues in more complex scenarios. It is possible that you attain this functionality manually as demonstrated in the sample project that is attached to this post.

Best regards,
Daniel
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
Malek
Top achievements
Rank 1
answered on 02 Jul 2009, 06:32 PM
Hi Daniel,

thank you for your reply ...

but Im not sure if you noticed that timePicker.Enabled (server code) and timePicker.set_enable(..) (client code) don't do the same !!!

timePicker.Enabled: enables or disables the entire timePicker, while timePicker.set_enable(..): enables or disables the embedded timeView !!!
Im in need to use both timePicker.TimeView.Enabled (server) and timePicker.set_enable() (client) (which are doing the same)
but timePicker.TimeView.Enabled ... doesn't work!! .... this is exactly my problem ... hope my explanatin is clear?

Thank you
Malek
0
Accepted
Martin
Telerik team
answered on 08 Jul 2009, 01:03 PM
Hi Malek,

As attached project you can find a sample solution to your scenario. Please note that i used Q2 2009 version. In this version the client side method Picker.set_enabled() is fixed and works as expected - disabling the entire picker control. I guess you are using an older version and that is why the method is not working properly on your side.
This fix is announced in the release history and you can review it here:
 http://www.telerik.com/products/aspnet-ajax/whats-new/release-history/q2-2009-version-2009-2-701.aspx

Regards,
Martin
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
Malek
Top achievements
Rank 1
answered on 09 Jul 2009, 12:16 AM
That is GREAT ...
you have completely solved my issue ....

I didn't get Q2 release yet ... I'll get it and let you know

Thank you Martin
0
Malek
Top achievements
Rank 1
answered on 09 Jul 2009, 12:09 PM
Thank you very much Martin for your help ...

I've test it ... it is working good now .... exactly like I need

thank you again
Malek
Tags
Calendar
Asked by
Malek
Top achievements
Rank 1
Answers by
Johny
Top achievements
Rank 1
Malek
Top achievements
Rank 1
Daniel
Telerik team
ataya
Top achievements
Rank 1
Martin
Telerik team
Share this question
or