Click here to Skip to main content
15,903,012 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionFind item in Generic List Pin
shapper12-Mar-07 11:53
shapper12-Mar-07 11:53 
Questionregistering some javascript code from within an user control Pin
gus_br12-Mar-07 11:39
gus_br12-Mar-07 11:39 
AnswerRe: registering some javascript code from within an user control Pin
Sandeep Akhare12-Mar-07 22:34
Sandeep Akhare12-Mar-07 22:34 
Questionasp+ajax Pin
biaali12-Mar-07 8:14
biaali12-Mar-07 8:14 
AnswerRe: asp+ajax Pin
SABhatti12-Mar-07 8:39
SABhatti12-Mar-07 8:39 
QuestionCurrency Pin
Sam Heller12-Mar-07 7:53
Sam Heller12-Mar-07 7:53 
AnswerRe: Currency Pin
SABhatti12-Mar-07 7:56
SABhatti12-Mar-07 7:56 
AnswerRe: Currency Pin
Kschuler12-Mar-07 8:12
Kschuler12-Mar-07 8:12 
I had a project where I needed to restrict decimal point places also. I wrote this method:
Public Sub RestrictDecimalPlaces(ByVal txtSender As TextBox, ByVal intPlacesToTheRight As Integer)
    '***********************************************************************************
    '   This function will ensure that only one decimal point is allowed in a text box
    '   and that the user may only type in a certain number of digits to the right of
    '   the decimal point (as specified by the intPlacesToTheRight parm).
    '***********************************************************************************
    If txtSender.TextLength <> 0 Then
        Dim strTemp As String = txtSender.Text
        Dim straTemp() As String
        straTemp = strTemp.Split(".")
        Select Case straTemp.Length
            Case 1
                'No decimal point, so no problem
                Return
            Case 2
                'One decimal point, ensure specified chars to the right
                Select Case straTemp(1).Length
                    Case Is > intPlacesToTheRight
                        txtSender.Text = straTemp(0) & "." & straTemp(1).PadRight(intPlacesToTheRight, "0").Substring(0, intPlacesToTheRight)
                        txtSender.SelectionStart = txtSender.Text.Length
                End Select
            Case Else
                'More than one decimal point, remove extra
                txtSender.Text = straTemp(0) & "." & straTemp(1)
                txtSender.SelectionStart = txtSender.Text.Length
        End Select
    End If
End Sub


And used it in the KeyPress Event of textboxes I wanted to restrict, like this:
Private Sub txtInput_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtInput.KeyUp
    RestrictDecimalPlaces(sender, 4)
End Sub


However, I know this code still has some quirks...and it won't help when the user does a copy and paste into the textbox, so you will want to modify it or use other edits as well. Hope this helps.
AnswerRe: Currency Pin
rajmani12-Mar-07 19:25
rajmani12-Mar-07 19:25 
GeneralRe: Currency Pin
Sam Heller12-Mar-07 23:05
Sam Heller12-Mar-07 23:05 
Questioncan javascript method call another method in a c# script? Pin
r_jaz12-Mar-07 5:27
r_jaz12-Mar-07 5:27 
AnswerRe: can javascript method call another method in a c# script? Pin
SABhatti12-Mar-07 5:34
SABhatti12-Mar-07 5:34 
AnswerRe: can javascript method call another method in a c# script? Pin
RichardGrimmer12-Mar-07 6:44
RichardGrimmer12-Mar-07 6:44 
GeneralRe: can javascript method call another method in a c# script? Pin
r_jaz12-Mar-07 9:02
r_jaz12-Mar-07 9:02 
GeneralRe: can javascript method call another method in a c# script? Pin
RichardGrimmer15-Mar-07 6:32
RichardGrimmer15-Mar-07 6:32 
QuestionASP.NET mouse event Pin
CodeBoi12-Mar-07 5:25
CodeBoi12-Mar-07 5:25 
AnswerRe: ASP.NET mouse event Pin
SABhatti12-Mar-07 5:31
SABhatti12-Mar-07 5:31 
GeneralRe: ASP.NET mouse event Pin
CodeBoi12-Mar-07 6:06
CodeBoi12-Mar-07 6:06 
GeneralRe: ASP.NET mouse event Pin
SABhatti12-Mar-07 6:15
SABhatti12-Mar-07 6:15 
GeneralRe: ASP.NET mouse event [modified] Pin
CodeBoi12-Mar-07 6:21
CodeBoi12-Mar-07 6:21 
AnswerRe: ASP.NET mouse event Pin
netJP12L12-Mar-07 5:39
netJP12L12-Mar-07 5:39 
GeneralRe: ASP.NET mouse event Pin
CodeBoi12-Mar-07 6:04
CodeBoi12-Mar-07 6:04 
QuestionDynamic Controls HELP --URGENT Pin
percyvimal12-Mar-07 5:22
percyvimal12-Mar-07 5:22 
AnswerRe: Dynamic Controls HELP --URGENT Pin
SABhatti12-Mar-07 5:36
SABhatti12-Mar-07 5:36 
AnswerRe: Dynamic Controls HELP --URGENT Pin
badgrs12-Mar-07 5:50
badgrs12-Mar-07 5:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.