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

ReadOnly RadNumericTextBox not firing OnFocus()

8 Answers 183 Views
Input
This is a migrated thread and some comments may be shown as answers.
Thad
Top achievements
Rank 2
Thad asked on 27 Nov 2011, 07:33 PM
Hello,

When I set ReadOnly=true on a RadNumericTextBox via markup, the client event OnFocus() does not fire.
<telerik:RadNumericTextBox CssClass="FarmSerialNumber" ID="rntbAcreageFarmSerialNumber"
    runat="server" Width="40px" Value='<%# DoubleFromDb(Eval("FarmSerialNumber"), true) %>'
    ReadOnly='<%# DoubleFromDb(Eval("FarmSerialNumber"), true) != null %>' MinValue="1">
    <NumberFormat DecimalDigits="0" GroupSeparator="" />
    <IncrementSettings InterceptMouseWheel="false" />
    <ReadOnlyStyle ForeColor="Gray"></ReadOnlyStyle>
    <ClientEvents OnValueChanged="radNumericTextBox_ClientValueChanged" OnFocus="acreageControl_ClientFocus" />
</telerik:RadNumericTextBox>

The documentation does not mention that this doesn't fire when it is readonly.
http://www.telerik.com/help/aspnet-ajax/input-client-side-onfocus.html

To ensure that this is not a problem with the <input> element, I added this and it works fine.
<input type="text" onfocus="alert('Yup.  Works')" readonly="readonly" />

Is this a bug or by design?

Thanks!
Thad

8 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 28 Nov 2011, 06:13 PM
Hello Thad,

By design focus and blur client events are not fired when the Input is ReadOnly.

All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Thad
Top achievements
Rank 2
answered on 28 Nov 2011, 09:24 PM
Hi Vasil,

I would highly suggest reconsidering this design decision.  This is not a limitation of the html INPUT or asp.net TextBox control, so it should not be a limitation of the RadInput control.  I can come up with many perfectly valid reasons why someone would want JavaScript code to fire off when a ReadOnly control gets focus.

Unfortunately, it sounds like the only workaround I have is to have two controls instead of one and display a readonly asp:textbox if there is a value already entered and display the telerik:radnumerictextbox if no value has been entered. 

Thad
0
Thad
Top achievements
Rank 2
answered on 28 Nov 2011, 09:25 PM
Hi Vasil,

I would highly suggest reconsidering this design decision.  This is not a limitation of the html INPUT or asp.net TextBox control, so it should not be a limitation of the RadInput control.  I can come up with many perfectly valid reasons why someone would want JavaScript code to fire off when a ReadOnly control gets focus.

Unfortunately, it sounds like the only workaround I have is to have two controls instead of one and display a readonly asp:textbox if there is a value already entered and display the telerik:radnumerictextbox if no value has been entered. 

Thad
0
Thad
Top achievements
Rank 2
answered on 28 Nov 2011, 09:25 PM
Hi Vasil,

I would highly suggest reconsidering this design decision.  This is not a limitation of the html INPUT or asp.net TextBox control, so it should not be a limitation of the RadInput control.  I can come up with many perfectly valid reasons why someone would want JavaScript code to fire off when a ReadOnly control gets focus.

Unfortunately, it sounds like the only workaround I have is to have two controls instead of one and display a readonly asp textbox if there is a value already entered and display the telerik radnumerictextbox if no value has been entered. 

Thad
0
Thad
Top achievements
Rank 2
answered on 28 Nov 2011, 09:26 PM
Um, I keep getting an "Oops..." message when posting a reply, but it's posting anyway.  Sorry for the multiple posts.
0
Accepted
Vasil
Telerik team
answered on 30 Nov 2011, 10:51 AM
Hello Thad,

The design is such because the control is actually not in focus, you see that it's styling remain ReadOnly, and its value is the display value and so on.

However you see the cursor because the visible HTML input is focused. If you want to check if it is visible you could attach a handler to the onfocus DOM event of the visible input element.
For example this code should work for you:
<script type="text/javascript">
  function focused(sender, e)
  {
    alert("focused");
  }
</script>
<telerik:RadTextBox runat="server" onfocus="focused(this,event)" ReadOnly="true">
</telerik:RadTextBox>


Best wishes,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Thad
Top achievements
Rank 2
answered on 02 Dec 2011, 01:28 AM
Hi Vasil,

That is a very acceptable workaround.  Thank you!

Is it possible to at least add a note into the documentation regarding the fact that the control differs from the base controls?  Or a sample into the troubleshooting/application scenarios?  That would be very useful.

Thanks!
Thad
0
Vasil
Telerik team
answered on 02 Dec 2011, 09:43 AM
Hi Thad,

Thank you for the suggestion, we added a note in the events section of the help about the Input, It will be visible after the next upload of the site.

Best wishes,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Input
Asked by
Thad
Top achievements
Rank 2
Answers by
Vasil
Telerik team
Thad
Top achievements
Rank 2
Share this question
or