object does not contain a defination for Show and no extension method Show accepting a first argument of type object

  • Thread starter Thread starter Will255
  • Start date Start date
W

Will255

Guest
Hi guys. It is my first c# program where I'm trying to build a login app. I am facing the following error on Show, Add and UserName. e.g on the line "MessageBox.Show("Invalid UserName"); How do I resolve it?

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using WinUX.Mvvm.Services;

// The Blank Page item template is documented at C#, VB, and C++ project templates for Store apps

namespace Airline_Reservation_Application.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Signup_page : Page
{
IsolatedStorageFile ISOFile = IsolatedStorageFile.GetUserStoreForApplication();
private object MessageBox;
private string gender;

public IEnumerable<object> ObjUserDataList { get; private set; }

private void Submit_Click(object sender, RoutedEventArgs e)

{

//UserName Validation

if (!Regex.IsMatch(TxtUserName.Text.Trim(), @"^[A-Za-z_][a-zA-Z0-9_\s]*$"))

{

MessageBox.Show("Invalid UserName");

}



//Password length Validation

else if (TxtPwd.Password.Length < 6)

{

MessageBox.Show("Password length should be <g class="gr_ gr_381 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="381" id="381">minimum</g> of 6 characters!");

}



//Address Text Empty Validation

else if (TxtAddr.Text == "")

{

MessageBox.Show("Please enter your address!");

}



//Gender Selection Empty Validation

else if (gender == "")

{

MessageBox.Show("Please select gender!");

}



//Phone Number Length Validation

else if (TxtPhNo.Text.Length != 10)

{

MessageBox.Show("Invalid PhonNo");

}



//EmailID validation

else if (!Regex.IsMatch(TxtEmail.Text.Trim(), @"^([a-zA-Z_])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$"))

{

MessageBox.Equals("Invalid EmailId");

}



//After validation success ,store user detials in isolated storage

else if (TxtUserName.Text != "" && TxtPwd.Password != "" && TxtAddr.Text != "" && TxtEmail.Text != "" && gender != "" && TxtPhNo.Text != "")

{

UserData ObjUserData = new UserData();

ObjUserData.UserName = TxtUserName.Text;

ObjUserData.Password = TxtPwd.Password;

ObjUserData.Address = TxtAddr.Text;

ObjUserData.Email = TxtEmail.Text;

ObjUserData.Gender = gender;

ObjUserData.PhoneNo = TxtPhNo.Text;

int Temp = 0;

foreach (var UserLogin in ObjUserDataList)

{

if (ObjUserData.UserName == UserLogin.UserName)

{

Temp = 1;

}

}

//Checking existing <g class="gr_ gr_377 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="377" id="377">user names</g> in local DB

if (Temp == 0)

{

ObjUserDataList.Add(ObjUserData);

if (ISOFile.FileExists("RegistrationDetails"))

{

ISOFile.DeleteFile("RegistrationDetails");

}

using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("RegistrationDetails", FileMode.Create))

{

DataContractSerializer serializer = new DataContractSerializer(typeof(List<UserData>));



serializer.WriteObject(fileStream, ObjUserDataList);



}

MessageBox.Show("Congrats! your have successfully Registered.");

NavigationService.Navigate(new Uri("/Views/Login.xaml", UriKind.Relative));

}

else

{

MessageBox.Show("Sorry! <g class="gr_ gr_378 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="378" id="378">user name</g> <g class="gr_ gr_380 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="380" id="380">is already existed</g>.");

}



}

else

{

MessageBox.Show("Please enter all details");

}

}
}

internal class UserData
{
internal string UserName;

public string Password { get; internal set; }
public string Address { get; internal set; }
public string Email { get; internal set; }
public string Gender { get; internal set; }
public string PhoneNo { get; internal set; }
}
}

Continue reading...
 
Back
Top