Silverlight Drag and Drop TreeView

Wednesday, July 7, 2010



Update From Dataset ADO.Net

Sunday, July 4, 2010


he System.Data namespace consists mostly of the classes that constitute the ADO.NET architecture. The ADO.NET architecture enables you to build components that efficiently manage data from multiple data sources. In a disconnected scenario (such as the Internet), ADO.NET provides the tools to request, update, and reconcile data in multiple tier systems.

//Initialize Connection from database

SqlConnection cn = new SqlConnection("connectionString");

//add this Query command with connectionstring parameters to data adopter to get schema form database

SqlDataAdapter da = new SqlDataAdapter("Select * from tablename",cn);

// Dataset Object

DataSet ds = new DataSet();

//fill database schema to dataset

da.FillSchema(ds, SchemaType.Mapped);


DataRow dRow1 = ds.Tables["workers"].NewRow();

dRow1[1] = "Value1"; //textBox1.Text;

dRow1[2] ="Value2"; //textBox2.Text;

dRow1[3] ="Value3";///textBox3.Text;

dRow1[4] = "Value4";///textBox4.Text;

dRow1[5] = "Value5";//textBox5.Text;

ds.Tables["workers"].Rows.Add(dRow1);

SqlCommandBuilder builder = new SqlCommandBuilder(da);

da.Update(ds);

ds.AcceptChanges();

Thank Microsoft for Send me Lovely Gifts Thank

Thursday, July 1, 2010

Few Days ago Microsoft Pakistan send a gift hamper with lots writing pad and in the morning i get big gift pack for Microsoft USA THANK FOR GIFTS I LOVE THE I LOVE THE SHIRTS THANK YOU











flotable Window demo

Wednesday, June 30, 2010

In Silverlight beta Microsoft provide us a Control called Childwindow.


Childwindow it just like we use Midi form in Desktop Windows Application or child form in base form window or you can say that Multiple form in one page but when we use silver-light ChildWindow Control it disable the parent Form. thats mean`s you can not work on parent form before close child-windows and you can not open Multiple child window in parent page to use them like flotable Windows or panels.ChildWindow has to be the top-most element in the Xaml. thats why its always on top and disable all parent controls .silverlight provide us another control for popup its called Popup Control so i just add ChildWindow in Popup as Child and open and close the popup thats i got base and beautiful functionality Childwindow like Floating ,dialog and i can interact with parent form as well or open Multiple childwindows in one form


 



 



<UserControl x:Class="SilverlightFlotingChildWindow.MainPage"



xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"



xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"



xmlns:d="http://schemas.microsoft.com/expression/blend/2008"



xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"



mc:Ignorable="d" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"



>



<Canvas x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">



<Button Content="Window 1" Height="23" HorizontalAlignment="Left" Margin="59,270,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />



<Button Content="Window 2" Height="23" HorizontalAlignment="Left" Margin="140,270,0,0" Name="button2" VerticalAlignment="Top" Width="75" Click="button2_Click" />



<Button Content="Window 3" Height="23" HorizontalAlignment="Left" Margin="221,270,0,0" Name="button3" VerticalAlignment="Top" Width="75" Click="button3_Click" />


</Canvas>

</UserControl>



 



 



using System;



using System.Collections.Generic;



using System.Linq;



using System.Net;



using System.Windows;



using System.Windows.Controls;



using System.Windows.Documents;



using System.Windows.Input;



using System.Windows.Media;



using System.Windows.Media.Animation;



using System.Windows.Shapes;


namespace SilverlightFlotingChildWindow

{


public partial class MainPage : UserControl

{


public MainPage()

{



InitializeComponent();



}



 


private void button1_Click(object sender, RoutedEventArgs e)

{


ChildWindow flotwin =
new ChildWindow();flotwin.Title = "Blue Window";

 


System.Windows.Controls.Primitives.Popup popup =
new System.Windows.Controls.Primitives.Popup();

 



flotwin.MouseLeftButtonDown += (a, x) =>



{


this.LayoutRoot.Children.Remove(popup);

this.LayoutRoot.Children.Add(popup);


popup.IsOpen =
true;

};



 


flotwin.Content =
new StackPanel()

{


Background =
new SolidColorBrush(Colors.Blue),

Height = 300,



Width = 300



};



flotwin.Closing +=(ss,ee)=>



{


popup.IsOpen =
false;

};



popup.Child = flotwin;


popup.IsOpen =
true;

 



 



 



LayoutRoot.Children.Add(popup);



}


private void button2_Click(object sender, RoutedEventArgs e)

{


ChildWindow flotwin =
new ChildWindow();

flotwin.Title = "Orange Window";


System.Windows.Controls.Primitives.Popup popup =
new System.Windows.Controls.Primitives.Popup();

 



flotwin.MouseLeftButtonDown += (a, x) =>



{


this.LayoutRoot.Children.Remove(popup);

this.LayoutRoot.Children.Add(popup);


popup.IsOpen =
true;

};


flotwin.Content =
new StackPanel()

{


Background =
new SolidColorBrush(Colors.Orange),

Height = 300,



Width = 300



};



flotwin.Closing += (ss, ee) =>



{


popup.IsOpen =
false;

};



popup.Child = flotwin;


popup.IsOpen =
true;

LayoutRoot.Children.Add(popup);



}


private void button3_Click(object sender, RoutedEventArgs e)

{


ChildWindow flotwin =
new ChildWindow();

 


flotwin.Title =
"Purple Window";System.Windows.Controls.Primitives.Popup popup = new System.Windows.Controls.Primitives.Popup();

 



flotwin.MouseLeftButtonDown += (a, x) =>



{


this.LayoutRoot.Children.Remove(popup);

this.LayoutRoot.Children.Add(popup);


popup.IsOpen =
true;

};


flotwin.Content =
new StackPanel()

{


Background =
new SolidColorBrush(Colors.Purple),

Height = 300,



Width = 300



};



flotwin.Closing += (ss, ee) =>



{


popup.IsOpen =
false;

};



popup.Child = flotwin;


popup.IsOpen =
true;

LayoutRoot.Children.Add(popup);



}



}





Download Source Code


Entity Framework with Linq CRUD Operation Example

Friday, June 25, 2010

Download Tutorial


Download Source Code

Usama Wahab KHan

Asp.net Server Side State Management

Wednesday, June 23, 2010


No web application framework, no matter how advanced, can change that HTTP is a stateless protocol. So inherently we should also forget our users, but unfortunately we cannot.ASP.Net Framework provides us features by which we can maintain states of your users. We can Manage State on Application ans Session Level
  • Session State
  • Application State
Session State:
It stores user specific information on server side.
There are 5 modes which a user can define for Session States;
  1. Off

  1. InProc

  1. StateServer

  1. SQLServer
  1. Custom
Sessions can and can not be cookie based.
The default name for this Session based cookie is Asp.Ner_SessionId We

Session state is structured as a key/value dictionary for storing session-specific information that needs to be maintained between server round trips and between requests for pages.
You can use session state to accomplish the following tasks:

Uniquely identify browser or client-device requests and map them to an individual session instance on the server.

Store session-specific data on the server for use across multiple browser or client-device requests within the same session.

Raise appropriate session management events. In addition, you can write application code leveraging these events

Sessions (In Proc)
When the configuration is set to InProc, session data is stored in the HTTPRuntime’s internal cache in an implementation of ISessionItemCollection that implements ICollection.
Stores Session in ASP.Net in-memory cache.


Sessions (State Server)
Also known as out of process.
Sessions states are held in a process called aspnet_state.exe that runs as a Windows Service.
Objects to be stored in StateServer sessions requires to be Serializable.
By default State Service is not running.

timeout=“20”/>
>
Sessions (Sql Server)
Sql Server based state management is not effected by farming or gardening issues.
Enable Sql Server support by running aspnet regsql -? Command to access and enable Session State Option.
Aspnet_regsql –S machine\servername –d statemanagement –U sa –P new –ssadd –sstype c
Sessions Recommendations
  • InProc is the fastest but most unreliable
  • StateServer is a better option but requires Serialization. It is slower than InProc as objects physically leave the application.
  • SQLServer is the most reliable and robust but is the slowest but also helpful when it comes to application scalability.
Declaring a Session Variable



string firstName = "Usama";
string lastName = "Khan";
string city = "Karachi";
Session["FirstName"] = firstName;
Session["LastName"] = lastName;
Session["City"] = city;
Using Session Variable




TxtfirstName
.Text
=
Session["FirstName"];
Txt
lastName
.Text
=
Session["LastName"]
;
Txt
city.Text =
Session["City"]
;

Application State
Application state is a data repository available to all classes in an ASP.NET application. Application state is stored in memory on the server and is faster than storing and retrieving information in a database. Unlike session state, which is specific to a single user session, application state applies to all users and sessions. Therefore, application state is a useful place to store small amounts of often-used data that does not change from one user to another
Global does not mean global to the machine, but global to the application.
Look for global.asax file.

Application state is stored in an instance of the HttpApplicationState class. This class exposes a key-value dictionary of objects.

Declaring Application Variable

In Application_Start handler of your application's Global.asax

Application["Message"] = "Welcome to Evolution Technologies ";

Application["PageRequestCount"] = 0;

Application.Lock();

Application["PageRequestCount"] =

((int)Application["PageRequestCount"])+1;

Application.UnLock();


Three Days Multi-Touch Training Session At MIC

Friday, June 18, 2010








Microsoft Pakistan has arranged a technical training camp on Windows 7 Multi-Touch platform to develop application’s using WPF and Silverlight 4.

Trainer:
Ali Khawaja
Principal Consultant at Microsoft
logo_82x23

Training Camp Outline
Day – 1

Track #Description
1

Introduction to Multi Touch

2-aIntroduction to WPF & Silverlight 4
2-bIntroduction to WPF & Silverlight 4 Lab
3-aMultitouch (Basics of Windows 7 Multitouch and its APIs)

3-b

Multitouch Lab
4-aDrag and Drop, Printing, and Multi-touch in Silverlight
4-bDrag and Drop, Printing, and Multi-touch in Silverlight Lab

Day – 2

Track #Description
1-aWPF/Silverlight Validation, Binding, DataForm and DataGrid
1-bWPF/Silverlight Validation, Binding, DataForm and DataGrid Lab

2

Implementing a Scenario using Multi Touch
3-aRibbon (Different aspects of the Windows 7 Ribbon and how to incorporate the Windows 7 Ribbon into existing applications.)
3-bRibbon Lab

Microsoft Also Arranged a contest on Multi-Touch Application Development and i won that and got dinar 100 and its Was such a great experience and Trainer was such help . I like to Thanks Microsoft Arranged this kinda event in Pakistan such a great effort by mic ,Noman Sohai,Jibran Jamsha,Talha Mahmood,Naveed bajwa and etl
and Special thank to Ali Khawaja visiting Pakistan