Hi,
I have a change password form, which I would like to check :
1.it shouldn't be empty or null
2.txtNewpassword.Text = txtConfimPassword.Text
How to write if statement for those conditions./
Thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Apr 25, 2013, 6:24 AM
hi,
try
string newPassword = txtNewpassword.Text;
string confirmPassword = txtConfimPassword.Text;
if (!string.IsNullOrEmpty(newPassword) && !string.IsNullOrEmpty(newPassword) && newPassword.Equals(confirmPassword))
{
//do change password.
}
else
{
//show the error.
}
hope this will help you.
Shankar MPosted Apr 25, 2013, 4:01 AM
You can use check for null or empty values using string.IsNullOrEmpty method of string class.
if(string.IsNullOrEmpty(txtNewpassword.Text))
{
MessageBox.Show("Please enter values");
return;
}
Satyapriya NayakPosted Apr 9, 2013, 9:54 PM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Fetch_multi_in_combobox
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (txtNewpassword.Text == "" || txtConfimPassword.Text == "")
{
MessageBox.Show("Please enter values");
return;
}
if (txtConfimPassword.Text != txtNewpassword.Text)
{
MessageBox.Show("confirm password not matching with new passsword");
txtConfimPassword.Focus();
return;
}
}
}
}