Archive for November 2013
Windows phone 8 C# code to check network or internet or wifi availablility
C# code in Windows phone 8 apps to display message in message box saying Network not available to update data when internet is not available in phone.
bool isNetwork = NetworkInterface.GetIsNetworkAvailable();
if (!isNetwork)
{
MessageBox.Show("Network not available to update data");
}
else {
//code to work when network is available
}
bool isNetwork = NetworkInterface.GetIsNetworkAvailable();
if (!isNetwork)
{
MessageBox.Show("Network not available to update data");
}
else {
//code to work when network is available
}
Windows phone 8 Sqlite queries to insert update delete in C# xaml app
C# code in windows phone 8 app with sqlite commands
string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
private void BtnUpdate_OnClick(object sender, RoutedEventArgs e)
{
using (var db = new SQLiteConnection(dbPath))
{
db.DeleteAll<RechargePlansData>();
db.RunInTransaction(() =>
{
for (int i = 0; i < d.l.Count; i++)
{
db.Insert(new RechargePlansData() { statename = 1, networkname = 1, categoryname = 1, amount = "2000", talktime = "2200", validity = "1 months", descriptiondata = "voda description1" });
}
});
}
private void BtnUpdate_OnClick(object sender, RoutedEventArgs e)
{
using (var db = new SQLiteConnection(dbPath))
{
var existing = db.Query<Person>("select * from Person").FirstOrDefault();
if (existing != null)
{
existing.FirstName = "Denis";
db.RunInTransaction(() =>
{
db.Update(existing);
});
}
}
}
private void BtnDelete_OnClick(object sender, RoutedEventArgs e)
{
using (var db = new SQLiteConnection(dbPath))
{
var existing = db.Query<Person>("select * from Person").FirstOrDefault();
if (existing != null)
{
db.RunInTransaction(() =>
{
db.Delete(existing);
});
}
}
}
C# code in RechargePlansData class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WP8Sqlite
{
class RechargePlansData
{
[SQLite.PrimaryKey, SQLite.AutoIncrement]
public int Id { get; set; }
public int statename { get; set; }
public int networkname { get; set; }
public int categoryname { get; set; }
public string amount { get; set; }
public string talktime { get; set; }
public string validity { get; set; }
public string descriptiondata { get; set; }
}
}
Windows Phone 8 C# code to consume asmx webservice with ADO.NET code
I added web service in references of my windows phone 8 app.
DbakingsReference is the ServiceName i gave. This is used as namespace in C# code.
RechargePlansService is the class inside my webservice.
GetData is the web method i created in webservice which returns data in form of a user defined type named data.
//return type
DbakingsReference is the ServiceName i gave. This is used as namespace in C# code.
RechargePlansService is the class inside my webservice.
GetData is the web method i created in webservice which returns data in form of a user defined type named data.
Here is the code in web service asmx file containing web method that returns data which is retreived from sql server database using ADO.NET
using System.Web.Services;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class RechargePlansService : System.Web.Services.WebService {
public RechargePlansService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString);
[WebMethod]
public data GetData()
{
data d = new data(); ;
SqlCommand cmd = new SqlCommand("select * from tbl_data", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
int i = 0;
List<string> l1 = new List<string>();
for ( i = 0; i < ds.Tables[0].Rows.Count; i++)
{
l1.Add( ds.Tables[0].Rows[i][0].ToString() + "," + ds.Tables[0].Rows[i][1].ToString() );
}
d.l = l1;
return d;
}
//return type
public class data
{
public List<string> l;
}
}
Code in Windows phone app to display data retreived from web service in a message box
private void Btn1_Click(object sender, EventArgs e)
{
DbakingsReference.RechargePlansServiceSoapClient MyClient = new DbakingsReference.RechargePlansServiceSoapClient();
MyClient.GetDataCompleted += MyClient_GetDataCompleted;
MyClient.GetDataAsync();
}
private void MyClient_GetDataCompleted(object sender, DbakingsReference.GetDataCompletedEventArgs e)
{
DbakingsReference.data d= e.Result;
MessageBox.Show ( d.l[0]);
}
MVC 4 Part-2 Creating first MVC4 application
Step by Step demo to create MVC 4 application
File - New Project - Select C# - Web - ASP.NET MVC 4 Web Application
Project types - Empty contains nothing recommended for experts.
Basic contains some important MVC elements to use.
Internet application contains lot of required elements as default.
Select Basic to follow this example.
Select Razor as view engine to write razor code in the project.
Solution Explorer with project files structure
Steps to add a controller
Right click on the controller folder and click on add - controller.
Enter controller name as FirstController.
Actually here First is the name of the controller.
Select empty API controller as template and click on Add.
Index.cshtml is the default view which is displayed when project is executed.
It is located in Home folder inside Views folder in solution explorer.
URL routing
The url routing is defined in RouteConfig.cs file which is present inside App_Start folder.
In that which url is mapped to which controller is defined.
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
This default router says that if there in no controller mentioned in the url then Home will be the default Controller and if there is no action mentioned in the url then Index will be the action performed.
File - New Project - Select C# - Web - ASP.NET MVC 4 Web Application
Project types - Empty contains nothing recommended for experts.
Basic contains some important MVC elements to use.
Internet application contains lot of required elements as default.
Select Basic to follow this example.
Select Razor as view engine to write razor code in the project.
Solution Explorer with project files structure
Controllers to hold controllers in the project. Models folder to add models of the project and views folder to add views for the project. Scripts folder is where javascript and jquery files are added.
Steps to add a controller
Right click on the controller folder and click on add - controller.
Enter controller name as FirstController.
Actually here First is the name of the controller.
Select empty API controller as template and click on Add.
Index.cshtml is the default view which is displayed when project is executed.
It is located in Home folder inside Views folder in solution explorer.
URL routing
The url routing is defined in RouteConfig.cs file which is present inside App_Start folder.
In that which url is mapped to which controller is defined.
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
This default router says that if there in no controller mentioned in the url then Home will be the default Controller and if there is no action mentioned in the url then Index will be the action performed.
MVC 4 Overview Part-1
MVC stands for Model View Controller.
MVC is built on ASP.NET. In ASP.NET we create websites using webpages or web forms.
Web Pages applications can be created using Web Matrix or Visual studio. They will have .CSHTML as extension. Javascript and C# razor syntax code can be added to it.
Web Forms applications can be created using Visual studio. They will have .aspx files and .aspx.cs files. UI is created using dragging controls. Double click to create events.
MVC applications contains models for data and objects. Views generate user interface. Controllers interact with user actions. Visual Studio is used to create this apps. Code in .cshtml and .cs files. Precise control of HTML and URLs.
Configuration, State management, Membership and roles, catching is also there in MVC.
You can also include Web forms inside MVC application because all of them are ASP.NET.
Life cycle
When a request comes Controller will receive the request then communicate with model to retreive data.
The retrieved data is send to View which represents data visually to user.
MVC is built on ASP.NET. In ASP.NET we create websites using webpages or web forms.
Web Pages applications can be created using Web Matrix or Visual studio. They will have .CSHTML as extension. Javascript and C# razor syntax code can be added to it.
Web Forms applications can be created using Visual studio. They will have .aspx files and .aspx.cs files. UI is created using dragging controls. Double click to create events.
MVC applications contains models for data and objects. Views generate user interface. Controllers interact with user actions. Visual Studio is used to create this apps. Code in .cshtml and .cs files. Precise control of HTML and URLs.
Configuration, State management, Membership and roles, catching is also there in MVC.
You can also include Web forms inside MVC application because all of them are ASP.NET.
Life cycle
When a request comes Controller will receive the request then communicate with model to retreive data.
The retrieved data is send to View which represents data visually to user.
SQL Server 2012 Select query
Select
select 'test'When you execute the above select query it will print test as output
select * from tbl_register
The above query is used to print the whole table data named as tbl_register.
select name from tbl_register
The above query is used to print data of name column from table named as tbl_register.
Where
select name from tbl_register where id<3The above query is used to print data of name column from tbl_register table with id value less than 3 only.
select id, name from tbl_register where id<3 order by name
The above query is used to print data from id and name columns and the output will be sorted based on the name column data.
Distinct
select distinct name from tbl_registerThe above query will print data in name column without duplicates or repeated values.
alias
select name as username from tbl_register
select username = name from tbl_register
select name username from tbl_register
The above three queries will print data in name column with username as column name.
select name from tbl_register as register
select name from tbl_register register
The above two queries will create register as alias name for table name tbl_register which is used in joins.
case
select id, name,
case stat
when 'yes' then 'pass'
else 'fail'
end as
[status]
from tbl_register
The above query will print three columns id, name, status.
id, name columns data is printed along with one more column named as status which is not present in table.
the data under status column is based on stat column which is present under tbl_register.
if stat column value is yes then at that place pass is printed else fail is printed in status column in the output.
id, name columns data is printed along with one more column named as status which is not present in table.
the data under status column is based on stat column which is present under tbl_register.
if stat column value is yes then at that place pass is printed else fail is printed in status column in the output.
id name status
1 sudhir pass
2 raj fail
3 ram pass
4 gopi pass
5 sudhir fail
Joins
Inner joins
Outer joins
Cross joins
SQL Server 2012
Operators
Predicates - in, between, like
Comparision operators - <, >, =, <=, >=, <>, !=, !<, !>
Logical operators - and, or, not
Arthimetic operators - +, -, * , /, %
Concatenation - +
Functions
String function - substring, left, right, len, datalength, replace, replicate, upper, lower, utrim, ltrim
date and time functions - getdate, systdatetime, getutcdate, dateadd, datediff, year, month, day
aggregate functions - sum, min, max, avg, count
T-SQL
Controlling flow - if else, while, break, continue, begin end
error handling - try catch
transaction control - begin transaction, commit transaction, rollback transaction
Comments - -- or /* */
Predicates - in, between, like
Comparision operators - <, >, =, <=, >=, <>, !=, !<, !>
Logical operators - and, or, not
Arthimetic operators - +, -, * , /, %
Concatenation - +
Functions
String function - substring, left, right, len, datalength, replace, replicate, upper, lower, utrim, ltrim
date and time functions - getdate, systdatetime, getutcdate, dateadd, datediff, year, month, day
aggregate functions - sum, min, max, avg, count
T-SQL
Controlling flow - if else, while, break, continue, begin end
error handling - try catch
transaction control - begin transaction, commit transaction, rollback transaction
Comments - -- or /* */
Windows phone 8 apps using common template for all longlistselectors in pivot app xaml c#
In this example i created a template with grid and textblock to use it in 2 longlist selectors in pivot app.
XAML code with template in pivot page
<phone:PhoneApplicationPage
x:Class="PivotApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources >
<DataTemplate x:Key="GridTemplate">
<Grid Background="{StaticResource PhoneAccentBrush}" Margin="5">
<StackPanel VerticalAlignment="Bottom" Margin="5">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap"/>
</StackPanel>
</Grid>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<phone:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<phone:PivotItem Header="first">
<!--Double line list with text wrapping-->
<phone:LongListSelector LayoutMode="Grid" GridCellSize="180,180"
Margin="0,0,-12,0" ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource GridTemplate}"
>
</phone:LongListSelector>
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem Header="second">
<!--Double line list no text wrapping-->
<phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}"
GridCellSize="150,150"
LayoutMode="Grid"
ItemTemplate="{StaticResource GridTemplate}">
</phone:LongListSelector>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
XAML code with template in pivot page
<phone:PhoneApplicationPage
x:Class="PivotApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources >
<DataTemplate x:Key="GridTemplate">
<Grid Background="{StaticResource PhoneAccentBrush}" Margin="5">
<StackPanel VerticalAlignment="Bottom" Margin="5">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap"/>
</StackPanel>
</Grid>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<phone:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<phone:PivotItem Header="first">
<!--Double line list with text wrapping-->
<phone:LongListSelector LayoutMode="Grid" GridCellSize="180,180"
Margin="0,0,-12,0" ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource GridTemplate}"
>
</phone:LongListSelector>
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem Header="second">
<!--Double line list no text wrapping-->
<phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}"
GridCellSize="150,150"
LayoutMode="Grid"
ItemTemplate="{StaticResource GridTemplate}">
</phone:LongListSelector>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
Windows Phone apps pivot template with grid tiles inside it
By default every pivot app contains a long list selector with row template i.e., items inside it will be displayed in listview format. Now in this example i modified the xaml code to convert that list format to grid format using the below code.
In this example i created windows phone 8 app using C#/XAML pivot template.
Here is the modified code in MainPage.xaml to display first pivot item longlistselector items in grid format.
<phone:PhoneApplicationPage
x:Class="PivotApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<phone:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<phone:PivotItem Header="first">
<!--Double line list with text wrapping-->
<phone:LongListSelector LayoutMode="Grid" GridCellSize="180,180"
Margin="0,0,-12,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid Background="{StaticResource PhoneAccentBrush}" Margin="5">
<StackPanel>
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem Header="second">
<!--Double line list no text wrapping-->
<phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding LineOne}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineThree}" TextWrapping="NoWrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
In this example i created windows phone 8 app using C#/XAML pivot template.
Here is the modified code in MainPage.xaml to display first pivot item longlistselector items in grid format.
<phone:PhoneApplicationPage
x:Class="PivotApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<phone:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<phone:PivotItem Header="first">
<!--Double line list with text wrapping-->
<phone:LongListSelector LayoutMode="Grid" GridCellSize="180,180"
Margin="0,0,-12,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid Background="{StaticResource PhoneAccentBrush}" Margin="5">
<StackPanel>
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem Header="second">
<!--Double line list no text wrapping-->
<phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding LineOne}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineThree}" TextWrapping="NoWrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
What is Blend in Visual Studio?
MS Visual Studio is a development tool used to create different kinds of applications using technologies present in .NET framework.
MS Blend for Visual Studio is a tool used for designing some application which we develop using MS Visual Studio.
When you install MS Visual Studio 2012 or later versions Blend is installed along with it.
It is specially used in designing windows store apps.
When you are working with windows store apps in visual studio you can open your xaml pages in blend by selecting option Open in blend with a right click on xaml page in solution explorer.
MS Blend for Visual Studio is a tool used for designing some application which we develop using MS Visual Studio.
When you install MS Visual Studio 2012 or later versions Blend is installed along with it.
It is specially used in designing windows store apps.
When you are working with windows store apps in visual studio you can open your xaml pages in blend by selecting option Open in blend with a right click on xaml page in solution explorer.
HTML5 audio and video tags
HTML5 contains audio and video tags to play audio files and video files directly on the webpage without using any plugins.
Example HTML5 code with audio and video tags
<!DOCTYPE HTML>
<html>
<body>
<audio controls>
<source src="Krrish.mp3" type="audio/mpeg">
Your browser does not support this audio format.
</audio>
<video>
<source src="Krrish.mp4" type="video/mp4" />
</video>
</body>
</html>
Example HTML5 code with audio and video tags
<!DOCTYPE HTML>
<html>
<body>
<audio controls>
<source src="Krrish.mp3" type="audio/mpeg">
Your browser does not support this audio format.
</audio>
<video>
<source src="Krrish.mp4" type="video/mp4" />
</video>
</body>
</html>
HTML5 Introduction
HTML5 is used to create static webpages with 2d graphics, audio and video players which can be played without installing any flash plugins in browser.
It also have lot of new features like local storage, css3 support and so on.
Basic structure of HTML5 document
<!DOCTYPE HTML>
<html>
<body>
</body>
</html>
HTML5 contains semantic tags like header, article, nav, footer, ...
Header tag is used to hold heading tags present in html document.
article tag is used to hold multiple paragraph tags below to same article in html document.
nav tag is used to hold multiple navigation tags like anchor tags.?
footer tag is used to hold text which is displayed at the bottom of the page as footer.
<!DOCTYPE HTML>
<html>
<body>
<header>
<h1>SQL</h1>
<h>Structure Query Language</h>
</header>
<article>
<p>
This is paragraph1.
</p>
<p>
This is paragraph2.
</p>
</article>
<nav>
<a href="http://www.google.com">Click here to navigate to google</a>
<br/>
<a href="http://www.dbakings.com">Click here to navigate to dbakings website</a>
</nav>
<footer>
Copyrights goes here
</footer>
</body>
</html>
It also have lot of new features like local storage, css3 support and so on.
Basic structure of HTML5 document
<!DOCTYPE HTML>
<html>
<body>
</body>
</html>
HTML5 contains semantic tags like header, article, nav, footer, ...
Header tag is used to hold heading tags present in html document.
article tag is used to hold multiple paragraph tags below to same article in html document.
nav tag is used to hold multiple navigation tags like anchor tags.?
footer tag is used to hold text which is displayed at the bottom of the page as footer.
<!DOCTYPE HTML>
<html>
<body>
<header>
<h1>SQL</h1>
<h>Structure Query Language</h>
</header>
<article>
<p>
This is paragraph1.
</p>
<p>
This is paragraph2.
</p>
</article>
<nav>
<a href="http://www.google.com">Click here to navigate to google</a>
<br/>
<a href="http://www.dbakings.com">Click here to navigate to dbakings website</a>
</nav>
<footer>
Copyrights goes here
</footer>
</body>
</html>
C# Windows store app code to login by checking data in sql server database using webservice
C# code in Windows store app to login into app by checking data in sql server database using webservice
private async void btn_login_Click_1(object sender, RoutedEventArgs e)
{
ComplaintServiceReference1.complaintSoapClient obj = new complaintSoapClient();
var ds= await obj.loginAsync(txt_name.Text, Convert.ToString(txt_password.Text));
if (ds.Body.loginResult > 0)
{
this.Frame.Navigate(typeof(complaint));
}
else
{
txt_name.Text = "";
txt_password.Text = "";
}
}
webservice:
[WebMethod]
public int login(string name,string password)
{
string s = "select name,passward from registration where name='"+name+"'and passward='"+password+"'";
SqlConnection con = new SqlConnection("Data Source=FS8HH1S\\SQLEXPRESS;Initial Catalog=grievancedata;Integrated Security=True");
//SqlCommand cmd = new SqlCommand(s, con);
SqlDataAdapter da = new SqlDataAdapter(s,con);
DataSet ds = new DataSet();
da.Fill(ds);
int count=ds.Tables[0].Rows.Count;
return count;
}
Creating Child forms inside parent Windows form
Create a new windows form application
Select form and click on F4 to open its properties.
set the IsMDIContainer property to true.
Drag and drop menu control and add New and Close options under file in menu using autogenerated textboxes as shown in the below image.
VB.NET code
Select form and click on F4 to open its properties.
set the IsMDIContainer property to true.
Drag and drop menu control and add New and Close options under file in menu using autogenerated textboxes as shown in the below image.
Create a new form named as form2 ie., right click on the project name in solution explorer - add new item - windows form - ok.
Now open form1 ie., our main form. Double click on the New (First item in menu) to generate click event to write the below c# code.
C# Code
Now open form1 ie., our main form. Double click on the New (First item in menu) to generate click event to write the below c# code.
C# Code
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 newMDIChild = new Form2();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
// Display the new form.
newMDIChild.Show();
}
VB.NET code
Protected Sub MDIChildNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Dim NewMDIChild As New Form2()
'Set the Parent Form of the Child window.
NewMDIChild.MdiParent = Me
'Display the new form.
NewMDIChild.Show()
End Sub
execute it Now you can see the form2 is displayed as child form inside form with a click on New menuitem.XAMLC# code to play audio using MediaElement in Windows Phone 8 apps
Playing Audio using MediaElement
Add audio files required to Assets folder.
XAML code for button with click event and media element with audio file as source
XAML code for button with click event and media element with audio file as source
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<Button Height="200" Width="200"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Background="Red"
Click="Button_Click_1"
>Play</Button>
<Button Height="200" Width="200"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Background="Red"
Click="Button_Click_2"
>Stop</Button>
</StackPanel>
<MediaElement x:Name="MElement"
Source="/Assets/Krrish.mp3"
Volume="50"
AutoPlay="False"
>
</MediaElement>
</Grid>
CSharp.net code in MainPage.xaml.cs page inside button click to play audio
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MElement.Play();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
MElement.Stop();