Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
    Single Page App
    Bootstrap
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> Windows Phone >> TextBox Control in Windows 7 Phone Development
TextBox Control in Windows 7 Phone Development
TextBox Control in Windows 7 Phone Development


by Arun Singh on 4/13/2012 4:06:47 PM

Views: 2194       Comments: 0

TextBox Control in Windows 7 Phone Development

With the TextBox control, the user can enter text in an application. Typically, a TextBox control is used to display, or accept as input, a single line of text. You can use the Multiline and ScrollBars properties to enable multiple lines of text to be displayed or entered. This article is going to explain how to use TextBox control in windows 7 phone development.

Getting started:

1.       Open Visual Studio

2.       Create new Silverlight Windows 7 Phone Development Project

3.       Enter your project Name

4.       Click on button ‘Ok’

TextBox Control in Windows 7 Phone Development

Now drag and drop Textbox control form toolbox into MainPage.xaml design page; after doing this set proper layout of textbox control.

TextBox Control in Windows 7 Phone Development

Now write down the following line of code to build this layout;

Code of ‘MainPage.xaml’ file:

<!--LayoutRoot is the root grid where all page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.RowDefinitions>

            <RowDefinition Height="Auto"/>

            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>

 

        <!--TitlePanel contains the name of the application and page title-->

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

            <TextBlock x:Name="ApplicationTitle" Text="My Application  " Style="{StaticResource PhoneTextNormalStyle}"/>

            <TextBlock x:Name="PageTitle" Text="Textbox Demo" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>

        </StackPanel>

 

        <!--ContentPanel - place additional content here-->

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

            <TextBlock Height="42" HorizontalAlignment="Left" Margin="30,6,0,0" Name="lblEmpDetails" Text="Employee Details" VerticalAlignment="Top" Width="366" DataContext="{Binding}" FontSize="32" />

            <TextBlock Height="50" HorizontalAlignment="Left" Margin="30,75,0,0" Name="lblName" Text="Emp Name" VerticalAlignment="Top" Width="165" FontSize="28" />

            <TextBox Height="72" HorizontalAlignment="Left" Margin="191,63,0,475" Name="txtName" Text="" VerticalAlignment="Center" Width="230" />

            <TextBlock Height="60" HorizontalAlignment="Left" Margin="35,163,0,0" Name="lblAddress" Text="Address" VerticalAlignment="Top" Width="118" FontSize="28" />

            <TextBox Height="72" HorizontalAlignment="Left" Margin="192,150,0,0" Name="txtAddress" Text="" VerticalAlignment="Top" Width="230" />

            <TextBlock Height="44" HorizontalAlignment="Left" Margin="36,247,0,0" Name="lblMobNo" Text="Mobile No." VerticalAlignment="Top" Width="144" FontSize="28" />

            <TextBox Height="72" HorizontalAlignment="Left" Margin="192,235,0,0" Name="txtMobNo" Text="" VerticalAlignment="Top" Width="229" />

            <Button Content="Submit" Height="72" HorizontalAlignment="Left" Margin="176,344,0,0" Name="btnSubmit" VerticalAlignment="Top" Width="160" Click="btnSubmit_Click" />

        </Grid>

    </Grid>

 

 


Code of MainPage.xaml.cs file:

using System.Windows;

using Microsoft.Phone.Controls;

 

namespace textBoxDemo

{

    public partial class MainPage : PhoneApplicationPage

    {

        // Constructor

        public MainPage()

        {

            InitializeComponent();

        }

 

        private void btnSubmit_Click(object sender, RoutedEventArgs e)

        {

            if (txtName.Text.Equals(string.Empty) || txtAddress.Text.Equals(string.Empty) || txtMobNo.Text.Equals(string.Empty))

                MessageBox.Show("Please fill all enteries");

            else

            MessageBox.Show("Data Successfull Submitted");

        }

 

       

    }

}

 

Now execute your program; following output will be appearing.

TextBox Control in Windows 7 Phone Development

Now fill all appropriate information in textfields and click on button ‘Submit’.

TextBox Control in Windows 7 Phone Development

This is the complete description about Textbox control in windows 7 phone development. I hope you will enjoy it.

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Arun SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 5038
Advertisement
MindStick SurveyManager
Advertise with Us
  
Copyright © 2014MindStick. All Rights Reserved.