Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 26th, 2007, 04:45 AM
Authorized User
 
Join Date: Jun 2007
Location: Pune, Maharastra, India.
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
  #2 (permalink)  
Old July 26th, 2007, 06:16 AM
Authorized User
 
Join Date: Apr 2007
Location: , , .
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.


  #3 (permalink)  
Old July 26th, 2007, 10:43 PM
vbn vbn is offline
Authorized User
 
Join Date: May 2005
Location: , , .
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


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:18 PM.


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