We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Check if Textinputlayout is empty


With a button i send an email , before i send it want to check if the Textinputlayout's are empty .

All fields must be filled before sending the email.

With a normal Entry i check it like this . 
But Textinputlayout not working , cannot be converted to string. What do i change

void OnVerzendButtonClicked(object sender, EventArgs args)
            if ( !string.IsNullOrWhiteSpace(EmailBody.Text) && !string.IsNullOrWhiteSpace(Voornaam.Text) && !string.IsNullOrWhiteSpace(Achternaam.Text))
                EmailSubject.Text = Voornaam.Text + " " + Achternaam.Text;
                var EmailTask = CrossMessaging.Current.EmailMessenger;

                if (EmailTask.CanSendEmail)
                    EmailTask.SendEmail("........@gmail.com", EmailSubject.Text, EmailBody.Text);

               _ = DisplayAlert("Error", "There are some empty fields !", "OK");


And in Xaml

<inputLayout:SfTextInputLayout x:Name="Voornaam" HelperText="Voornaam" AbsoluteLayout.LayoutBounds=".10,.82,.35,.55" AbsoluteLayout.LayoutFlags="All">
                        <Entry />
                    <inputLayout:SfTextInputLayout x:Name="Achternaam" HelperText="Achternaam" AbsoluteLayout.LayoutBounds=".88,.82,.48,.55" AbsoluteLayout.LayoutFlags="All">
                        <Entry />

                    <Entry x:Name="EmailSubject" Placeholder="Onderwerp Email" BackgroundColor="White" TextColor="Black"  FontSize="Small" AbsoluteLayout.LayoutBounds="30,330,300,35" AbsoluteLayout.LayoutFlags="None"/>

                    <Editor x:Name="EmailBody" Placeholder="Bericht" BackgroundColor="White" TextColor="Black"  FontSize="Small" AbsoluteLayout.LayoutBounds="30,350,300,15" AbsoluteLayout.LayoutFlags="None" />

1 Reply

RA Rachel A Syncfusion Team November 5, 2019 09:24 AM UTC

Hi Boris, 
Greetings from Syncfusion. 
To get the entry text which is placed inside text input layout, we can use InputView property as shown in the below code snippet. 
string text = (Voornaam.InputView as Entry).Text; 
Also, you can refer the documentation link to know more information on text input layout. 

Live Chat Icon For mobile
Up arrow icon