Search code examples
c#versionauto-update

C# Check if textbox == textbox


Why does this not work :

            if (This_Ver.Text == New_Ver.Text)
            {
                MAIN_PANEL.Visible = true;
            }
            else if (This_Ver.Text != New_Ver.Text)
            {
            DialogResult dialogResult = MessageBox.Show("An update has been found!" + Environment.NewLine + "Would you like to download and install it?", "Update found!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (dialogResult == DialogResult.Yes)
            {
                MAIN_PANEL.Visible = false;
                UPDATE_PANEL.Visible = true;
                USERNAME_TEXT.Enabled = false;
                PASSWORD_TEXT.Enabled = false;
                LOGIN_BUTTON.Enabled = false;
                MAIN_PANEL.Visible = false;
                UPDATE_NOW_BUTTON.Enabled = true;
            }
            else if (dialogResult == DialogResult.No)
            {
                UPDATE_NOW_BUTTON.Enabled = true;
                MAIN_PANEL.Visible = true;
            }
        }

I am trying to compare the new version and the current running version. It should open the updater panel when the textboxes does not contain the same version.

But It doesn't work. It always opens the updater panel.

EDIT :

value : This_Ver.Text : V1.1.13.1

value : New_Ver.Text : V1.1.13.1


Solution

  • Try like below may be it will help you you..

    change your code

    FROM :

    if (This_Ver.Text == New_Ver.Text)
    

    TO :

    if (This_Ver.Text.ToUpper().Trim().Equals(This_Ver.Text.ToUpper().Trim()))