Cannot parse error when closing popup

16 posts, 0 answers
  1. Stefan
    Stefan avatar
    4 posts
    Member since:
    Feb 2009

    Posted 26 Feb 2009 Link to this post

    Hi,

    I am using the latest version of RadControls for ASP.NET Ajax and get the following error (using Firefox) when returning from a Usercontrol popup window (running ASP.NET on a German Windows XP).
    Any hints would be greatly appreciated.

    Thanks,
    Stefan

    The numeric part ('161.5') of '161.5px' cannot be parsed as a numeric part of a Pixel unit.

    Stack Trace:

    [FormatException: The numeric part ('161.5') of '161.5px' cannot be parsed as a numeric part of a Pixel unit.]
       System.Web.UI.WebControls.Unit..ctor(String value, CultureInfo culture, UnitType defaultType) +508
       System.Web.UI.WebControls.Unit.Parse(String s) +63
       Telerik.Web.UI.RadGrid.LoadClientState(Dictionary`2 clientState) +946
       Telerik.Web.UI.RadCompositeDataBoundControl.LoadPostData(String postDataKey, NameValueCollection postCollection) +193
       Telerik.Web.UI.RadCompositeDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +42
       System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +693
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743
    
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2009 Link to this post

    Hi Stefan,

    I think you are trying to assign a  string  value to  unit  some where in your code,

    Try to convert the string value to unit as show below.

        width   = Unit.Pixel(161.5);

    _shinu. 








  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stefan
    Stefan avatar
    4 posts
    Member since:
    Feb 2009

    Posted 07 Mar 2009 Link to this post

    Hi Shinu,

    I have searched all files (code, css etc) but cannot find any statement like that. However, if I set the current culture to invariant in global.asax, the error disappears (System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;)

    As a consequence, all UI elements use English culture now so this is not an ideal solution.

    Thanks,
    Stefan


  5. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 01 May 2009 Link to this post

    Hi,

    I have the exact same problem when using Firefox 3.0.10 and the UI culture set to "fr-CA" when hitting the "X" close button. Hitting "cancel" does not cause the error. The error happens with Firefox and Safari for windows, not IE8, Opera or Chrome.

    Removing the ClientEvent OnPopupShowing seems to fix the problem. Here's is the code for PopUpShowing (adapted from this thread)

    function PopUpShowing(sender, eventArgs) 
        var popUp = eventArgs.get_popUp(); 
        var windowHeight = (window.innerHeight != undefined ? window.innerHeight : document.body.offsetHeight); 
        var windowWidth = document.body.offsetWidth; 
         
        var popUpWidth = popUp.style.width.substr(0,popUp.style.width.indexOf("px")); 
        var popUpHeight = popUp.style.height.substr(0,popUp.style.height.indexOf("px")); 
        popUp.style.left = ((windowWidth - popUpWidth)/2 + sender.get_element().offsetLeft).toString() + "px"
     
        var posXY = GetAbsPosXY(sender.get_element()); 
        var scrollXY = GetScrollXY(); 
        popUp.style.top = Math.max(posXY[1], scrollXY[1]).toString() + "px"
     

    Here is the error I receive :

    The numeric part ('573.5') of '573.5px' cannot be parsed as a numeric part of a Pixel unit.


    Do you have any work around ?

    Thanks

    dstj.

    using v2009.1.402.35
  6. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 04 May 2009 Link to this post

    Hi dstj,

    Can you please check whether appending "px" to the popup window's height/width values addresses the problem? Namely:

    function PopUpShowing(sender, eventArgs)    
    {    
        var popUp = eventArgs.get_popUp();    
        var windowHeight = (window.innerHeight != undefined ? window.innerHeight : document.body.offsetHeight) + "px";    
        var windowWidth = document.body.offsetWidth + "px";    
            
        var popUpWidth = popUp.style.width.substr(0,popUp.style.width.indexOf("px"));    
        var popUpHeight = popUp.style.height.substr(0,popUp.style.height.indexOf("px"));    
        popUp.style.left = ((windowWidth - popUpWidth)/2 + sender.get_element().offsetLeft).toString() + "px";    
        
        var posXY = GetAbsPosXY(sender.get_element());    
        var scrollXY = GetScrollXY();    
        popUp.style.top = Math.max(posXY[1], scrollXY[1]).toString() + "px";    
    }   
     

    If the problem remains, please let us know in order to research the matter further.

    Kind regards,

    Sebastian
    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.
  7. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 04 May 2009 Link to this post

    Thanks for your help,

    Appending "px" fixes the problem with Firefox, but creates a problem with IE8.

    Here is the javascript error I now receive before the popup is shown:
    Line: 184
    Error: Invalid argument."

    popUp.style.left = ((windowWidth - popUpWidth)/2 + sender.get_element().offsetLeft).toString() + "px"

    Two observations/questions:

    1- The Firefox problem is a server error when closing the popup, OnShowingPopup has already been called and worked. Why would modifying the javascript function do anything for the server error upon closing?

    2- We're removing the "px" in this code. Why should we add it to "windowWidth" ?
    var popUpWidth = popUp.style.width.substr(0,popUp.style.width.indexOf("px")); 

    Thanks

    Dominic.
     
  8. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 04 May 2009 Link to this post

    Hi Dominic,

    The observed problem is caused by the fact that Firefox 3 supports decimal (non-integer) pixel values, which the RadGrid control does not expect on the server. The issue is fixed in the last two official releases of RadControls (Q1 2009 and Q1 2009 SP1).

    In your case, if you don't want to upgrade, you can round the top and left styles for the popup and make sure that they are integer values.

    As far as I can see, you don't need "px" for the windowWidth variable, if you are using it to store a number (i.e. you are not using it to assign a CSS style directly).

    Best wishes,
    Dimo
    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.
  9. dstj
    dstj avatar
    82 posts
    Member since:
    Oct 2006

    Posted 04 May 2009 Link to this post

    Hi Dimo,

    Rounding does fix the problem, thanks for your help! I'm using v2009.1.402.35. At the time of writing, this seems to be the latest official build.

    I don't think the problem is with Firefox support for fractional pixels per say. I remind you that it works fine with an English UI culture. The problem probably is that the server-side parsing doesn't use the invariant culture to parse the fractional pixel returned by Firefox, hence it's expecting a coma (,) in French but received a period (.) from Firefox. Rounding only goes around the problem.

    Thanks again,

    Dominic.
  10. Shukhrat Nekbaev
    Shukhrat Nekbaev avatar
    73 posts
    Member since:
    Oct 2010

    Posted 29 Apr 2011 Link to this post

    Hi,

    was experiencing same issue with 2011.1.413.40 and Finnish language, also solved but rounding:

    var popUp;
    function PopUpShowing(sender, eventArgs) {
        popUp = eventArgs.get_popUp();
        var popUpWidth = popUp.style.width.substr(0, popUp.style.width.indexOf("px"));
        popUp.style.left = (Math.round(($(window).width() - popUpWidth) / 2 + sender.get_element().offsetLeft)).toString() + "px";
        popUp.style.top = $('#' + sender.ClientID).position().top + "px";
    }

    maybe someone will find this usefull :)
  11. Rafael
    Rafael avatar
    8 posts
    Member since:
    Aug 2013

    Posted 01 Oct 2013 Link to this post

    IE 11 is throwing this same error now.

    The OnPopUpShowing script is not helping because it happens on close.

    Is there a way to set the on close script?


  12. Galin
    Admin
    Galin avatar
    526 posts

    Posted 04 Oct 2013 Link to this post

    Hello Rafael,

    I am afraid the issue you are facing is not replicable on our side. Could you please send a small running project that we can use to reproduce the case. Alternatively a live URL will help us as well.

    Regards,
    Galin
    Telerik
    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 the blog feed now.
  13. Ron
    Ron  avatar
    16 posts
    Member since:
    Aug 2008

    Posted 15 Oct 2013 Link to this post

    Hi We have the same Issue Closing, pressing the  OK or Cancel button in a Grid Edit PopUp.
    We use Dutch Language settings and it only occurs when we change the position of the dialog during edit/insert.

    The application uses Telerik version v.2013.2.717.45

    The Message we get is:

    Unhandled exception at line 15, column 16485 in http://localhost:49573/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=;;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,+PublicKeyToken=31bf3856ad364e35:en-US:c9cbdec3-c810-4e87-846c-fb25a7c08002:ea597d4b:b25378d2;Telerik.Web.UI:en-US:4401a8f1-5215-4b97-a426-3601ce0fa0ff:16e4e7cd:f7645509:22a6274a:ed16cbdc:24ee1bba:19620875:874f8ea2:f46195d3:92fe8ea0:fa31b949:490a9d4e:bd8f85e4:e330518b:2003d0b8:1e771326:c8618e41:aa288e2d:58366029:8674cba1:7c926187:b7778d6c:c08e9f8a:e4f8f289:a51ee93e:59462f1

    0x800a139e - JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The numeric part ('501.85') of '501.85px' cannot be parsed as a numeric part of a Pixel unit.

    We do not use any JS that does does something wirh pixels or so. This smells like a bug to us and any help on this issue is apriciated.

    Thanks,
    Ron

  14. Developer Developer
    Developer Developer avatar
    1 posts
    Member since:
    Oct 2005

    Posted 16 Oct 2013 Link to this post

    Today I also saw this error in the logs. Also Dutch language, but the browser is IE 10. Telerik version 2013.2.717.40.

    Unfortunately I cannot reproduce...

    System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.FormatException: The numeric part ('50.52') of '50.52px' cannot be parsed as a numeric part of a Pixel unit.
       at System.Web.UI.WebControls.Unit..ctor(String value, CultureInfo culture, UnitType defaultType)
       at Telerik.Web.UI.RadGrid.LoadClientState(Dictionary`2 clientState)
       ...
  15. Galin
    Admin
    Galin avatar
    526 posts

    Posted 18 Oct 2013 Link to this post

    Hi,

    Thank you for sharing this issue to us.

    I forwarded it to our developers and it will be fixed in the internal build. In the meantime could you use the following JS workaround. Place it in the end of your page.

    if (Telerik.Web.UI.RadGrid)
    {
        Telerik.Web.UI.RadGrid.prototype._popUpMouseUp = function (e)
        {
            if (!this.canMove)
                return;
     
            this.canMove = false;
     
            var dragHandle = this.getElementsByTagName("div")[0];
            var popUpId = dragHandle.id;
            var tableViewId = popUpId.split("__")[0];
            var tableView = $find(tableViewId);
            if (tableView)
            {
                var grid = tableView._owner;
                grid._popUpLocations[popUpId] = Math.round(parseInt(this.style.left)) + "px," + Math.round(parseInt(this.style.top)) + "px";
                grid.updateClientState();
                grid.resizeModalBackground();
            }
            Telerik.Web.UI.Grid.RestoreDocumentEvents();
        }
    }

    I hope this helps.

    Regards,
    Galin
    Telerik
    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 the blog feed now.
  16. Michael
    Michael avatar
    4 posts
    Member since:
    Jun 2012

    Posted 12 Nov 2013 Link to this post

    Hi, I'm just wondering if the two of you experiencing this issue are using ASP.NET StateServer instead of InProc, as I am experiencing a similar issue with Telerik Reporting.

    I have been doing some testing to switch from InProc to StateServer and all of a sudden this error is occurring when I try run a Telerik Report. When I run my reports I get  "The numeric portion of 1,554px cannot be parsed as a unit of type Pixel.". This only occurs when the total width of the columns exceeds 1000px, as thats the point when the comma appears. The exception stack shows Telerik.Reporting.Drawing.Unit.Init at the top as the point where the exception is raised, clearly not something I will be able to control! 

    It seems to me there is a serious issue in the underlying framework as it is not using the InvariantCulture when serialising and deserialising values. 

    Telerik team - any plans to address this soon? 
  17. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 15 Nov 2013 Link to this post

    Hi Michael,

    This is a quote from your support ticket on the same question regarding Telerik Reporting:

    "The issue is not reproducible at our side whether the decimal separator is comma or dot. Please double check if you are applying through code conversion to double without applying invariant culture. You can test serializing the report instance in XML and checking how decimal values are stored in it.

    If you need further help, please send us a runnable sample project illustrating the issue, and details about the result of the above suggested test.
    "

    If you need further help, please update your support ticket with the requested information.

    Regards,
    Stef
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017