Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 26th, 2007, 04:45 AM
Authorized User
 
Join Date: Jun 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calling method in windows forms from text control

HI,

How can i call a method to validate atext box in windows forms?
I have currently written as
this.txtmno.LostFocus=Validate(txtmno.Text);
but its displaying error as the event "System.Windows.Form.Control.LostFocus should be on leftside of the =+-.
what may be possible solution to this.

Thanks

Prasnana
__________________
Thanks

Prasanna
 
Old July 26th, 2007, 06:16 AM
Authorized User
 
Join Date: Apr 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Firstly you have posted it in wrong subforum.
Secondly LostFocus is an event and you have wrongly tried to set value.


 
Old July 26th, 2007, 10:43 PM
vbn vbn is offline
Authorized User
 
Join Date: May 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

18. Validating the data entered in the Amount TextBox control.

This event occurs when the input focus leaves the control. This event procedure is to check for whether data entered in amount text box control is valid.

Private Sub mAmount_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles mAmount.LostFocus
    If Not IsNumeric(mAmount.Text) And mAmount.Text <> " " Then
        MsgBox("Not a Numeric Input! Try again.")
        mAmount.Focus()
        Exit Sub
    ElseIf (mAmount.Text < 0) Then
        MessageBox.Show("Enter positive Amount")
        mAmount.Focus()
        Exit Sub
    End If
End Sub


The TextChanged event occurs when the content in the TextBox control is changed. Select mAmount in LHS combobox and TextChanged in the RHS combobox to program this event. We use IsNumeric() function to check the value entered in the amount text box control is numeric data. We also check whether the value entered in this text box is empty. If any of these conditions are true, then we will display a message box and set the focus to the Amount text box control.

Private Sub mAmount_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mAmount.TextChanged
    If Not IsNumeric(mAmount.Text) And mAmount.Text <> " " Then
        MsgBox("Not a Numeric Input! Try again.")
        mAmount.Focus()
        Exit Sub
    End If
End Sub







Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a btn_click method dhirajDac ASP.NET 2.0 Professional 2 April 18th, 2008 07:52 AM
Calling a function on every method call Takashi321 General .NET 1 September 21st, 2007 09:33 AM
Calling a method from Linkbutton in DataList swifty_programmer ASP.NET 2.0 Basics 1 July 28th, 2007 05:32 AM
Error calling a method in the webservice madhusrp .NET Web Services 1 April 12th, 2007 08:54 AM
Wizard control in Windows Forms? wakeup Pro Visual Basic 2005 0 May 15th, 2006 10:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.