Geeks With Blogs
Jenson Code Ranch Code Ranch for Web and Mobile Development

If you have been using Ajax control toolkits a lot (which I will skip the parts on where to download and how to configure it in Visual Studio 2010), you might have encountered some bugs or limitations of the controls, or rather, some weird behaviours. I would call them weird behaviours though.

Recently, I've been working on a Ajax numeric updown control, which i remember clearly it was working fine without problems. In fact, I use 2 numeric updown control this time.

So I went on to configure it to be as simple as possible and I will just use the default up and down buttons provided by it (so that I won't need to design my own). I have two textbox controls to display the value controlled by the updown control. One for month, and another for year.

<asp:TextBox ID="txtMonth" runat="server" CssClass="txtNumeric" ReadOnly="True" Width="150px" />

<asp:TextBox ID="txtYear" runat="server" CssClass="txtNumeric" ReadOnly="True" Width="150px" />

So I will now drop 1 numeric updown control for each of the textboxes.

<asp:NumericUpDownExtender ID="txtMonth_NumericUpDownExtender"
    runat="server" TargetControlID="txtMonth" Maximum="12" Minimum="1" Width="152">
<asp:NumericUpDownExtender ID="txtYear_NumericUpDownExtender"
    runat="server" TargetControlID="txtYear" Width="152">
You noticed that I configure the Maximum and Minimum value for the first numericupdown control, but I never did the same for the second one (for txtYear). That's because it won't work, well, at least for me.

So I remove the Minimum="2000" and Maximum="2099" from there. Then I would configure the initial value to the the current year, and let the year to flow up and down freely. If you want, you want write the codes to restrict it.

Here are the codes I used on PageLoad:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

            If Trim(txtMonth.Text) = "" Then

                Me.txtMonth.Text = System.DateTime.Today.Month

            End If

            If Trim(txtYear.Text) = "" Then

                Me.txtYear.Text = System.DateTime.Today.Year

            End If

        End If

    End Sub


Posted on Wednesday, June 22, 2011 3:14 PM | Back to top

Comments on this post: [AJAX Numeric Updown Control] Microsoft JScript runtime error: The number of fractional digits is out of range

# re: [AJAX Numeric Updown Control] Microsoft JScript runtime error: The number of fractional digits is out of range
Requesting Gravatar...
Ajax is powerful tool and apply mostly .NET language. This language is easy to learn and use also. This is man tent many types of S/W.
Left by motorised treadmills on Jun 23, 2011 8:05 PM

Your comment:
 (will show your gravatar)

Copyright © Jenson | Powered by: