Increment server event

16 posts, 0 answers
  1. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 11 Jan 2013 Link to this post

    I have a web page with a RadNumericTextBox on it
    it needs to implement the following functionality
    if the user types in a number it  waits for the user to click a button to fill a grid
    if the user increments the box using the mouse wheel or arrow keys it fills a grid with the value of the textbox as a parameter

    please advise
  2. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 15 Jan 2013 Link to this post

    Telerik made this so easy - I already had a client-side key press event

    one question - can I style the spin buttons in any way?  the CSS class seems to be a read-only property
    <telerik:RadNumericTextBox ID="rntbPage" MinValue="1" MaxValue="9999" MaxLength="4" ShowSpinButtons="True" AutoPostBack="true" Font-Names="Verdana" Font-Size="X-Small" Height="22px" Width="72px" runat="server" >
        <NumberFormat DecimalDigits="0" GroupSeparator="" />
        <ClientEvents OnKeyPress="OnKeyPress" />
        <ClientEvents OnValueChanged="OnValueChanged" />
    </telerik:RadNumericTextBox>
    // do not allow entry of comma or dot in textboxes
    function OnKeyPress(sender, args) {
        dont_rebuild_grid = true;         
        var uniCode = args.get_keyCode();
        if (uniCode > 43 & uniCode < 47) {
            args.set_cancel(true);
        }
    }
     
    var dont_rebuild_grid = false;
    function OnValueChanged(sender, args) {           
        if (dont_rebuild_grid) {
            args.set_cancel(true);
        }
    }
    Protected Sub rntbPage_TextChanged(sender As Object, e As System.EventArgs) Handles rntbPage.TextChanged
        OnePageOfItems()
    End Sub
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 15 Jan 2013 Link to this post

    I am never going to learn how to program if Telerik keeps making things so easy.....

    to style the spin buttons, first put a skin on the textbox (counter-intuitive) i.e. Skin="Hay"
    then override the spin buttons for that skin in the CSS

    .radInput_Hay a.spinbutton
    {           
       font-size:larger !important;
       font-weight:bolder !important;
    }
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 16 Jan 2013 Link to this post

    Hi Marianne,

    Thank you for sharing you experience with our controls and posting your opinion. Do not hesitate to write back in case any issues with any of our components appear.

    All the best,
    Maria Ilieva
    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.
  6. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 16 Jan 2013 Link to this post

    I'm finding clicking the arrows triggers the event but the mouse wheel only changes the value in the textbox
    is there a way to make moving the mouse wheel trigger the client-side ValueChanged as well as the server-side TextChanged events?
  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 21 Jan 2013 Link to this post

    Hi Marianne,

    Note that the client ValueChanged and the server TextChanged event fire in case the text is submitted after blurring the control or pressing Enter key. The same behavior is applicable for the MouseWheel. In case the value is increment with the mouse wheel you need to blur the input and the mentioned events will fire

    Greetings,
    Maria Ilieva
    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.
  8. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 01 Feb 2013 Link to this post

    I found I had to add a client event on the button - the paging was becoming disabled if something was entered into the textbox
  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Feb 2013 Link to this post

    Hi Marianne,

    Thank you for updating us on this issue. I'm glad to hear you have found appropriate solution for your case.

    Regards,
    Maria Ilieva
    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.
  10. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 26 Feb 2014 Link to this post

    I would like the mouse wheel changes to trigger a change in the OnValueChanged.  How can I capture the wheelmouse and blur the test box so it fires the event?

    Also, on keypress too.

    I would think that by now this should be built into the control? Right?

    Marty
  11. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2014 in reply to moegal Link to this post

    Hi moegal,

    Please have a look into the sample code snippet to attach the onmousewheel , onkeypress and OnBlur event to RadNumericTextBox.

    ASPX:
    <telerik:RadNumericTextBox ID="RadTextBox1" runat="server" ClientEvents-OnBlur="OnBlur"
        onkeypress="KeyPress();" onmousewheel="MouseWheel();">
    </telerik:RadNumericTextBox>

    JavaScript:
    <script type="text/javascript">
        function OnBlur(sender, args) {
            alert("OnBlur");
            //your code
        }
        function KeyPress() {
            alert("KeyPress");
            //your code
        }
        function MouseWheel() {
            alert("MouseWheel");
            //your code
        }
    </script>

    Let me know if you have any concern.
    Thanks,
    Shinu.
  12. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 27 Feb 2014 in reply to Shinu Link to this post

    Shinu,

    thanks.  How do I get the sender on any of these?

    I am using a repeater and a master page or 2. 

    do I need to do something like this?  kludgy?

    onmousewheel='<%# string.Format("MouseWheel({0});", Eval("myid").ToString()) %>'

    Marty




  13. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Feb 2014 in reply to moegal Link to this post

    Hi moegal,

    Please try the following code snippet to achieve your scenario.

    ASPX:
    ...
    <telerik:RadTextBox ID="RadTextBox1" runat="server" onmousewheel="MouseWheel(this);"             Text='<%# DataBinder.Eval(Container.DataItem, "FileName").ToString() %>'>
     </telerik:RadTextBox>
    ...

    JavaScript:
    function MouseWheel(id) {
        var sender = id;
        //your code
    }

    Thanks,
    Shinu.
  14. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 28 Feb 2014 in reply to moegal Link to this post

    Still not working the way I would expect.

    onkeypress='<%# string.Format("KeyPress(\"{0}\");", ((RepeaterItem)Container).FindControl("qty").ClientID) %>'
                                    onmousewheel='<%# string.Format("MouseWheel(\"{0}\");", ((RepeaterItem)Container).FindControl("qty").ClientID) %>'
                                    onkeydown='<%# string.Format("return (event.keyCode != 13);KeyDown(\"{0}\");", ((RepeaterItem)Container).FindControl("qty").ClientID) %>'

    I had to block the enterkey because it was posting the page. Any way to stop the page from post back but still do my js code?  I cannot get it to work.

    Marty
  15. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2014 in reply to moegal Link to this post

    Hi moegal,

    Please try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server" onmousewheel="MouseWheel(this);" onkeypress="KeyPress(event,this);" Text=' <%# DataBinder.Eval(Container.DataItem, "FileName").ToString() %>'>
    </telerik:RadTextBox>

    JavaScript:
    function KeyPress(key,id) {
        if (key.keyCode == 13)
            key.preventDefault();
    }

    Thanks,
    Shinu.
  16. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 05 Mar 2014 in reply to Shinu Link to this post

    Shinu,

    thanks but it still seems to post the page.  My RadNumericTextBox and RadButton are in a Repeater and it seems that the event for RadButtonAdd_Click is getting fired when I hit enter while my focus is in the RadNumericTextBox .

    Any way to prevent that?

    Marty


  17. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 05 Mar 2014 in reply to moegal Link to this post

    seems adding UseSubmitBehavior="false" to the RadButton did the trick.

    Thanks, Marty
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017