Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. How to compare two textbox values in windows forms?

How to compare two textbox values in windows forms?

Scheduled Pinned Locked Moved Windows Forms
csharphelpasp-netwinformstutorial
2 Posts 2 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    irkahc
    wrote on last edited by
    #1

    Hi how to validate two textbox values. ex, there are two textboxes, password and confirm password.. I want to compare these two. we can use comparevalidator in ASP.net. how can we do in windows forms..? can any one send me code? thanks in advance? am using asp.net 2.0 and C#.. I have used errorProvider control. see the following code.. if (txtFirstName.Text.Trim().Length == 0) // working fine { errorProvider1.SetError(txtFirstName, "This Field Can not be empty."); } if (txtUnitID.Text.Trim().Length == 0) //working fine { errorProvider1.SetError(txtUnitID, "This Field Can not be empty."); } // not working if (txtPassword.Text.Trim() != txtConfirmPwd.Text.Trim()) // not working. { errorProvider1.SetError(txtConfirmPwd, "Password not matched."); } I have written this code in save button click event. ex, if pwd is not equal it not showing error message. wat is the problem..?

    A 1 Reply Last reply
    0
    • I irkahc

      Hi how to validate two textbox values. ex, there are two textboxes, password and confirm password.. I want to compare these two. we can use comparevalidator in ASP.net. how can we do in windows forms..? can any one send me code? thanks in advance? am using asp.net 2.0 and C#.. I have used errorProvider control. see the following code.. if (txtFirstName.Text.Trim().Length == 0) // working fine { errorProvider1.SetError(txtFirstName, "This Field Can not be empty."); } if (txtUnitID.Text.Trim().Length == 0) //working fine { errorProvider1.SetError(txtUnitID, "This Field Can not be empty."); } // not working if (txtPassword.Text.Trim() != txtConfirmPwd.Text.Trim()) // not working. { errorProvider1.SetError(txtConfirmPwd, "Password not matched."); } I have written this code in save button click event. ex, if pwd is not equal it not showing error message. wat is the problem..?

      A Offline
      A Offline
      Ali el
      wrote on last edited by
      #2

      i tried it in vb.NET and its work fine my code is: If TextBox1.Text.Trim = TextBox2.Text.Trim Then MessageBox.Show("Yep") Else MessageBox.Show("Nep") End If i dunt know where is the error

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups