[C#/ASP.NET] RadNumericTextbox does not trigger any client events

3 posts, 1 answers
  1. Michiel
    Michiel avatar
    12 posts
    Member since:
    Feb 2011

    Posted 25 Sep 2012 Link to this post

    I have developed a page where I have used the following controls:

    RadGrid
    RadTabStrip
    RadDatePicker
    RadNumericTextBox

    On this page caching is enabled so every control I use here on the page I need to set the following properties:

    EnableEmbeddedBaseStylesheet = false;
    EnableEmbeddedScripts = false;
    EnableEmbeddedSkins = false;
    RegisterWithScriptManager = false;


    I have added the scripts of the controls dynamically in my MasterPage via the following code snippet:

    var scripts = new List<ScriptReference>();
     
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadGrid)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadTabStrip)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadMultiPage)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadComboBox)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadInputManager)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadFilter)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadMenu)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadContextMenu)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadInputControl)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadMaskedTextBox)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadToolTip)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadToolTipManager)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadNumericTextBox)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadUpload)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadAsyncUpload)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadTreeView)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadTextBox)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadCalendar)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadDatePicker)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadDateTimePicker)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadMonthYearPicker)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadTimeView)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadTimePicker)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadDateInput)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadScriptManager)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadAjaxManager)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadToolBar)));
    scripts.AddRange(ScriptObjectBuilder.GetScriptReferences(typeof(RadDate)));
     
    foreach (var script in scripts)
       RadScriptManager1.Scripts.Add(script);

    The above code section works because all other controls work how they should be except the RadNumericTextBox.

    On that page which I have developed I have a RadTabStrip with two tabs. In the second tab I have rendered the RadNumericTextBox via the codebehind with the following code:

    var ctl = new RadNumericTextBox();
    ctl.ID = "RandomId";
    ctl.NumberFormat.AllowRounding = false;
    ctl.NumberFormat.DecimalDigits  = 0;
    ctl.NumberFormat.GroupSeparator = "";
    ctl.MinValue = 1;
    ctl.MaxValue = int.MaxValue;
    ctl.ClientEvents.OnKeyPress = "onKeyPress";
    ctl.ClientEvents.OnBlur = "onBlur";
    ctl.Value = 1;
    ctl.EnableEmbeddedBaseStylesheet = false;
    ctl.EnableEmbeddedScripts = false;
    ctl.EnableEmbeddedSkins = false;
    ctl.RegisterWithScriptManager = false;

    Which have some client events which are not worth to mention because they validate if the user presses ',' that this is not allowed in the RadNumericTextBox and when the user leaves the RadNumericTextBox and it is empty that the value is reset to the default (minimal value).

    The problem is that sometimes the RadNumericTextBox works but when I press CTRL + F5 or just restart my webpage the RadNumericTextBox does not work anymore. Somehow client events are not triggered when the user interacts with this RadNumericTextBox.

    I have validated that the $create method is rendered on the page and also is called. Based on this idea (because we had a similair problem before with the RadTabStrip) I have decided to add an additional client event: onNumericClientLoad which simulates again the $create method. Somehow this doesn't work either.

        $create(Telerik.Web.UI.RadNumericTextBox, {
            "_displayText": sender.get_value(),
            "_focused": false,
            "_initialValueAsText": sender.get_value(),
            "_postBackEventReferenceScript": sender._postBackEventReferenceScript,
            "_skin": sender._skin,
            "_validationText": sender.get_value(),
            "clientStateFieldID": sender._clientStateFieldID,
            "enabled": true,
            "incrementSettings": { InterceptArrowKeys: true, InterceptMouseWheel: true, Step: 1 },
            "maxValue": sender.get_maxValue(),
            "minValue": sender.get_minValue(),
            "numberFormat": { "DecimalDigits": 0, "DecimalSeparator": ",", "CultureNativeDecimalSeparator": ",", "GroupSeparator": "", "GroupSizes": 3, "NegativePattern": "-n", "NegativeSign": "-", "PositivePattern": "n", "AllowRounding": false, "KeepNotRoundedValue": false, "KeepTrailingZerosOnFocus": false, "NumericPlaceHolder": "n" },
            "styles": { HoveredStyle: ["width:160px;", "riTextBox riHover"], InvalidStyle: ["width:160px;", "riTextBox riError"], DisabledStyle: ["width:160px;", "riTextBox riDisabled"], FocusedStyle: ["width:160px;", "riTextBox riFocused"], EmptyMessageStyle: ["width:160px;", "riTextBox riEmpty"], ReadOnlyStyle: ["width:160px;", "riTextBox riRead"], EnabledStyle: ["width:160px;", "riTextBox riEnabled"], NegativeStyle: ["width:160px;", "riTextBox riNegative"] }
        }, { "keyPress": onKeyPress, "blur": onBlur }, null, $get(sender.get_id()));  


    I'm really lost now why this is not working, I hope someone can help me to get the client events working with this RadNumericTextBox.

    Details:
    Development Environment: Visual Studio 2010 Professional
    Framework: .NET 4.0
    Controls: ASP.NET Controls
    Version: 2012.2.912.40

  2. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 28 Sep 2012 Link to this post

    Hi Michael,

    In case a caching functionality is needed for the presented page I would suggest you to use Telerik CDN as a better approach. I suppose that the issue you are facing appear due to the fact that the needed for the Input control resources are loaded too late on the page.
    The Telerik CDN provides the required functionality and will be better option for your application. See the help topic below for more information on this matter:
    http://www.telerik.com/help/aspnet-ajax/scriptmanager-cdn-support.html


    Kind 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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michiel
    Michiel avatar
    12 posts
    Member since:
    Feb 2011

    Posted 10 Oct 2012 Link to this post

    Hello Maria,

    I'm sorry that I respond this late but I was already able to resolve it. Somehow I needed to disable all caching capabilities, navigate to the page where I make use of the RadNumericTextBox, hit CTRL + F5 and after that enable all caching capabilities. This resulted in that the RadNumericTextBox started to work :).
Back to Top