System.OverflowException during IPostBackDataHandler.LoadPostData

Discussion in 'ASP .Net Building Controls' started by Nathan Sokalski, Jul 20, 2006.

  1. During my postbacks, I try to assign the value from an Input tag to a
    property of a custom control. However, I keep recieving the following error:


    An exception of type 'System.OverflowException' occurred in
    Microsoft.VisualBasic.dll but was not handled in user code
    Additional information: Arithmetic operation resulted in an overflow.


    The code that it highlights during this error is the 2nd line of the
    following (Me.Value = postCollection(Me.ID & "_currvalue")):


    Public Function LoadPostData(ByVal postDataKey As String, ByVal
    postCollection As NameValueCollection) As Boolean Implements
    IPostBackDataHandler.LoadPostData
    Me.Value = postCollection(Me.ID & "_currvalue")
    Return True
    End Function


    I will admit that this is my first time using the IPostBackDataHandler
    interface, but 'System.OverflowException' seems like a very strange
    exception for this part of my code, since I am just doing a String
    concatenation and an assignment. The value associated with this
    postCollection key is a positive integer (well, a string actually, but it
    has no negative signs or decimal places, just a couple digits) and Me.Value
    is a Property of my Control that is of type Integer, so it shouldn't have
    any problem converting, right? If anybody has any ideas as to where I might
    be going wrong here, or where I could look to help find the problem, I would
    appreciate it. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Jul 20, 2006
    #1
    1. Advertising

  2. Nathan Sokalski

    Teemu Keiski Guest

    What does the Value property and RaisePostDataChanged method (another method
    of IPostBackDataHandler) look like? If the code isn't long oner, post entire
    control's sources.


    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke



    "Nathan Sokalski" <> wrote in message
    news:%...
    > During my postbacks, I try to assign the value from an Input tag to a
    > property of a custom control. However, I keep recieving the following
    > error:
    >
    >
    > An exception of type 'System.OverflowException' occurred in
    > Microsoft.VisualBasic.dll but was not handled in user code
    > Additional information: Arithmetic operation resulted in an overflow.
    >
    >
    > The code that it highlights during this error is the 2nd line of the
    > following (Me.Value = postCollection(Me.ID & "_currvalue")):
    >
    >
    > Public Function LoadPostData(ByVal postDataKey As String, ByVal
    > postCollection As NameValueCollection) As Boolean Implements
    > IPostBackDataHandler.LoadPostData
    > Me.Value = postCollection(Me.ID & "_currvalue")
    > Return True
    > End Function
    >
    >
    > I will admit that this is my first time using the IPostBackDataHandler
    > interface, but 'System.OverflowException' seems like a very strange
    > exception for this part of my code, since I am just doing a String
    > concatenation and an assignment. The value associated with this
    > postCollection key is a positive integer (well, a string actually, but it
    > has no negative signs or decimal places, just a couple digits) and
    > Me.Value is a Property of my Control that is of type Integer, so it
    > shouldn't have any problem converting, right? If anybody has any ideas as
    > to where I might be going wrong here, or where I could look to help find
    > the problem, I would appreciate it. Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    Teemu Keiski, Jul 20, 2006
    #2
    1. Advertising

  3. Here is the code for the Value property:


    <Description("The value that the Slider is currently set to")>
    <DefaultValue("0")> _
    Public Property Value() As Integer
    Get
    If IsNothing(ViewState("value")) Then Return 0 Else Return
    ViewState("value")
    End Get
    Set(ByVal value As Integer)
    ViewState("value") = value
    End Set
    End Property


    And here is the code for the RaisePostDataChangedEvent method:


    Public Sub RaisePostDataChangedEvent() Implements
    IPostBackDataHandler.RaisePostDataChangedEvent
    End Sub


    The only code in my OnPreRender method other than the creating of the
    client-side scripts, which I do using String concatenation and the
    Page.ClientScript.RegisterClientScriptBlock method, is setting the only
    global variable I have, which is declared as Private pixeltovalue As
    Decimal, as follows:


    Me.pixeltovalue = (Me.Width - 48) / (Me.MaxValue - Me.MinValue)


    My Render method just uses the basic methods of the HtmlTextWriter class.
    The only arithmetic operations in my OnPreRender and Render methods are very
    simple addition, subtraction, multiplication, and division. I did not think
    it was worth pasting all my code into this message (although I can if you
    really think it will help you solve the problem), since almost all of it is
    property declarations, all of which look exactly the same as the one above,
    String concatenation while building the JavaScript functions, and the basic
    HtmlTextWriter methods used to create the html tags; the only other code in
    my control is the IPostBackDataHandler implementation and the
    Me.pixeltovalue declaration and assignment that I showed above. Any ideas as
    to what the problem might be? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Teemu Keiski" <> wrote in message
    news:...
    > What does the Value property and RaisePostDataChanged method (another
    > method of IPostBackDataHandler) look like? If the code isn't long oner,
    > post entire control's sources.
    >
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:%...
    >> During my postbacks, I try to assign the value from an Input tag to a
    >> property of a custom control. However, I keep recieving the following
    >> error:
    >>
    >>
    >> An exception of type 'System.OverflowException' occurred in
    >> Microsoft.VisualBasic.dll but was not handled in user code
    >> Additional information: Arithmetic operation resulted in an overflow.
    >>
    >>
    >> The code that it highlights during this error is the 2nd line of the
    >> following (Me.Value = postCollection(Me.ID & "_currvalue")):
    >>
    >>
    >> Public Function LoadPostData(ByVal postDataKey As String, ByVal
    >> postCollection As NameValueCollection) As Boolean Implements
    >> IPostBackDataHandler.LoadPostData
    >> Me.Value = postCollection(Me.ID & "_currvalue")
    >> Return True
    >> End Function
    >>
    >>
    >> I will admit that this is my first time using the IPostBackDataHandler
    >> interface, but 'System.OverflowException' seems like a very strange
    >> exception for this part of my code, since I am just doing a String
    >> concatenation and an assignment. The value associated with this
    >> postCollection key is a positive integer (well, a string actually, but it
    >> has no negative signs or decimal places, just a couple digits) and
    >> Me.Value is a Property of my Control that is of type Integer, so it
    >> shouldn't have any problem converting, right? If anybody has any ideas as
    >> to where I might be going wrong here, or where I could look to help find
    >> the problem, I would appreciate it. Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
    Nathan Sokalski, Jul 20, 2006
    #3
  4. Nathan Sokalski

    Teemu Keiski Guest

    Hi,

    could it be that the

    Me.Value = postCollection(Me.ID & "_currvalue")

    would be so big number it doesn't fit to the value? (32-bit Integer). Where
    does this value come from? Is it calculated, entered by user?


    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke



    "Nathan Sokalski" <> wrote in message
    news:...
    > Here is the code for the Value property:
    >
    >
    > <Description("The value that the Slider is currently set to")>
    > <DefaultValue("0")> _
    > Public Property Value() As Integer
    > Get
    > If IsNothing(ViewState("value")) Then Return 0 Else Return
    > ViewState("value")
    > End Get
    > Set(ByVal value As Integer)
    > ViewState("value") = value
    > End Set
    > End Property
    >
    >
    > And here is the code for the RaisePostDataChangedEvent method:
    >
    >
    > Public Sub RaisePostDataChangedEvent() Implements
    > IPostBackDataHandler.RaisePostDataChangedEvent
    > End Sub
    >
    >
    > The only code in my OnPreRender method other than the creating of the
    > client-side scripts, which I do using String concatenation and the
    > Page.ClientScript.RegisterClientScriptBlock method, is setting the only
    > global variable I have, which is declared as Private pixeltovalue As
    > Decimal, as follows:
    >
    >
    > Me.pixeltovalue = (Me.Width - 48) / (Me.MaxValue - Me.MinValue)
    >
    >
    > My Render method just uses the basic methods of the HtmlTextWriter class.
    > The only arithmetic operations in my OnPreRender and Render methods are
    > very simple addition, subtraction, multiplication, and division. I did not
    > think it was worth pasting all my code into this message (although I can
    > if you really think it will help you solve the problem), since almost all
    > of it is property declarations, all of which look exactly the same as the
    > one above, String concatenation while building the JavaScript functions,
    > and the basic HtmlTextWriter methods used to create the html tags; the
    > only other code in my control is the IPostBackDataHandler implementation
    > and the Me.pixeltovalue declaration and assignment that I showed above.
    > Any ideas as to what the problem might be? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "Teemu Keiski" <> wrote in message
    > news:...
    >> What does the Value property and RaisePostDataChanged method (another
    >> method of IPostBackDataHandler) look like? If the code isn't long oner,
    >> post entire control's sources.
    >>
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke
    >>
    >>
    >>
    >> "Nathan Sokalski" <> wrote in message
    >> news:%...
    >>> During my postbacks, I try to assign the value from an Input tag to a
    >>> property of a custom control. However, I keep recieving the following
    >>> error:
    >>>
    >>>
    >>> An exception of type 'System.OverflowException' occurred in
    >>> Microsoft.VisualBasic.dll but was not handled in user code
    >>> Additional information: Arithmetic operation resulted in an overflow.
    >>>
    >>>
    >>> The code that it highlights during this error is the 2nd line of the
    >>> following (Me.Value = postCollection(Me.ID & "_currvalue")):
    >>>
    >>>
    >>> Public Function LoadPostData(ByVal postDataKey As String, ByVal
    >>> postCollection As NameValueCollection) As Boolean Implements
    >>> IPostBackDataHandler.LoadPostData
    >>> Me.Value = postCollection(Me.ID & "_currvalue")
    >>> Return True
    >>> End Function
    >>>
    >>>
    >>> I will admit that this is my first time using the IPostBackDataHandler
    >>> interface, but 'System.OverflowException' seems like a very strange
    >>> exception for this part of my code, since I am just doing a String
    >>> concatenation and an assignment. The value associated with this
    >>> postCollection key is a positive integer (well, a string actually, but
    >>> it has no negative signs or decimal places, just a couple digits) and
    >>> Me.Value is a Property of my Control that is of type Integer, so it
    >>> shouldn't have any problem converting, right? If anybody has any ideas
    >>> as to where I might be going wrong here, or where I could look to help
    >>> find the problem, I would appreciate it. Thanks.
    >>> --
    >>> Nathan Sokalski
    >>>
    >>> http://www.nathansokalski.com/
    >>>

    >>
    >>

    >
    >
    Teemu Keiski, Jul 21, 2006
    #4
  5. No, that was not the problem, but I found that in my client-side JavaScript
    I needed to explicitly convert a text value to a Number, I was ending up
    with a value like "25-1" being sent to the server instead of 24, but thanks
    for your help anyway.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > could it be that the
    >
    > Me.Value = postCollection(Me.ID & "_currvalue")
    >
    > would be so big number it doesn't fit to the value? (32-bit Integer).
    > Where does this value come from? Is it calculated, entered by user?
    >
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >> Here is the code for the Value property:
    >>
    >>
    >> <Description("The value that the Slider is currently set to")>
    >> <DefaultValue("0")> _
    >> Public Property Value() As Integer
    >> Get
    >> If IsNothing(ViewState("value")) Then Return 0 Else Return
    >> ViewState("value")
    >> End Get
    >> Set(ByVal value As Integer)
    >> ViewState("value") = value
    >> End Set
    >> End Property
    >>
    >>
    >> And here is the code for the RaisePostDataChangedEvent method:
    >>
    >>
    >> Public Sub RaisePostDataChangedEvent() Implements
    >> IPostBackDataHandler.RaisePostDataChangedEvent
    >> End Sub
    >>
    >>
    >> The only code in my OnPreRender method other than the creating of the
    >> client-side scripts, which I do using String concatenation and the
    >> Page.ClientScript.RegisterClientScriptBlock method, is setting the only
    >> global variable I have, which is declared as Private pixeltovalue As
    >> Decimal, as follows:
    >>
    >>
    >> Me.pixeltovalue = (Me.Width - 48) / (Me.MaxValue - Me.MinValue)
    >>
    >>
    >> My Render method just uses the basic methods of the HtmlTextWriter class.
    >> The only arithmetic operations in my OnPreRender and Render methods are
    >> very simple addition, subtraction, multiplication, and division. I did
    >> not think it was worth pasting all my code into this message (although I
    >> can if you really think it will help you solve the problem), since almost
    >> all of it is property declarations, all of which look exactly the same as
    >> the one above, String concatenation while building the JavaScript
    >> functions, and the basic HtmlTextWriter methods used to create the html
    >> tags; the only other code in my control is the IPostBackDataHandler
    >> implementation and the Me.pixeltovalue declaration and assignment that I
    >> showed above. Any ideas as to what the problem might be? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>
    >> "Teemu Keiski" <> wrote in message
    >> news:...
    >>> What does the Value property and RaisePostDataChanged method (another
    >>> method of IPostBackDataHandler) look like? If the code isn't long oner,
    >>> post entire control's sources.
    >>>
    >>>
    >>> --
    >>> Teemu Keiski
    >>> ASP.NET MVP, AspInsider
    >>> Finland, EU
    >>> http://blogs.aspadvice.com/joteke
    >>>
    >>>
    >>>
    >>> "Nathan Sokalski" <> wrote in message
    >>> news:%...
    >>>> During my postbacks, I try to assign the value from an Input tag to a
    >>>> property of a custom control. However, I keep recieving the following
    >>>> error:
    >>>>
    >>>>
    >>>> An exception of type 'System.OverflowException' occurred in
    >>>> Microsoft.VisualBasic.dll but was not handled in user code
    >>>> Additional information: Arithmetic operation resulted in an overflow.
    >>>>
    >>>>
    >>>> The code that it highlights during this error is the 2nd line of the
    >>>> following (Me.Value = postCollection(Me.ID & "_currvalue")):
    >>>>
    >>>>
    >>>> Public Function LoadPostData(ByVal postDataKey As String, ByVal
    >>>> postCollection As NameValueCollection) As Boolean Implements
    >>>> IPostBackDataHandler.LoadPostData
    >>>> Me.Value = postCollection(Me.ID & "_currvalue")
    >>>> Return True
    >>>> End Function
    >>>>
    >>>>
    >>>> I will admit that this is my first time using the IPostBackDataHandler
    >>>> interface, but 'System.OverflowException' seems like a very strange
    >>>> exception for this part of my code, since I am just doing a String
    >>>> concatenation and an assignment. The value associated with this
    >>>> postCollection key is a positive integer (well, a string actually, but
    >>>> it has no negative signs or decimal places, just a couple digits) and
    >>>> Me.Value is a Property of my Control that is of type Integer, so it
    >>>> shouldn't have any problem converting, right? If anybody has any ideas
    >>>> as to where I might be going wrong here, or where I could look to help
    >>>> find the problem, I would appreciate it. Thanks.
    >>>> --
    >>>> Nathan Sokalski
    >>>>
    >>>> http://www.nathansokalski.com/
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Nathan Sokalski, Jul 21, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. One Handed Man \( OHM - Terry Burns \)

    Custom Control & System.Web.UI.IPostBackDataHandler.LoadPostData

    One Handed Man \( OHM - Terry Burns \), Jun 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,933
    One Handed Man \( OHM - Terry Burns \)
    Jun 17, 2004
  2. =?Utf-8?B?YnJpYW4ubWlsbHM=?=

    IPostBackDataHandler.LoadPostData

    =?Utf-8?B?YnJpYW4ubWlsbHM=?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    3,425
    William F. Robertson, Jr.
    Apr 25, 2005
  3. Nathan Sokalski
    Replies:
    4
    Views:
    417
    Nathan Sokalski
    Jul 21, 2006
  4. Nathan Sokalski
    Replies:
    5
    Views:
    1,335
    Nathan Sokalski
    Sep 27, 2007
  5. Nathan Sokalski

    Retrieving contained Controls during postback using LoadPostData

    Nathan Sokalski, Sep 27, 2007, in forum: ASP .Net Building Controls
    Replies:
    5
    Views:
    764
    Nathan Sokalski
    Sep 27, 2007
Loading...

Share This Page