using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConstructorSeq
{
class Program
{
public class A
{
public A()
{
Console.WriteLine("I am A");
}
static A()
{
Console.WriteLine("I am static A");
}
}
public class B:A
{
public B()
{
Console.WriteLine("I am B");
}
static B()
{
Console.WriteLine("I am static B");
}
}
static void Main(string[] args)
{
B b = new B(); //This outputs
//I am Static B
Console.ReadLine(); //I am Static A
} //I am A
//I am B
}
}
=================================================================================
But this static constructor execution pattern changes in this 3 level inheritance
=================================================================================
class Program
{
public Program()
{
Console.WriteLine("I am p");
}
static Program()
{
Console.WriteLine("I am sp");
}
class Program1:Program
{
public Program1()
{
Console.WriteLine("I am p1");
}
static Program1()
{
Console.WriteLine("I am sp1");
}
}
class Program2 : Program1
{
public Program2()
{
Console.WriteLine("I am p2");
}
static Program2()
{
Console.WriteLine("I am sp2");
}
}
static void Main(string[] args)
{
Program2 p2 = new Program2();
Console.ReadLine();
}
}
}
//Check out the difference between the two
Wednesday, April 23, 2008
Dynamic Binding with datahiding query
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.FrameWork;
namespace DynamicBindingWithHiding
{
class A
{
public virtual void Whoareyou()
{
Console.WriteLine("I am in A");
Console.ReadLine();
}
}
class B:A
{
public override void Whoareyou()
{
Console.WriteLine("I am in B");
Console.ReadLine();
}
}
class C : B
{
public new virtual void Whoareyou()
{
Console.WriteLine("I am in C");
Console.ReadLine();
}
}
class D : C
{
public override void Whoareyou()
{
Console.WriteLine("I am in D");
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
//C c = new D();
//c.Whoareyou();
A a = new D();
a.Whoareyou(); //It shows "I am in B" how?
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.FrameWork;
namespace DynamicBindingWithHiding
{
class A
{
public virtual void Whoareyou()
{
Console.WriteLine("I am in A");
Console.ReadLine();
}
}
class B:A
{
public override void Whoareyou()
{
Console.WriteLine("I am in B");
Console.ReadLine();
}
}
class C : B
{
public new virtual void Whoareyou()
{
Console.WriteLine("I am in C");
Console.ReadLine();
}
}
class D : C
{
public override void Whoareyou()
{
Console.WriteLine("I am in D");
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
//C c = new D();
//c.Whoareyou();
A a = new D();
a.Whoareyou(); //It shows "I am in B" how?
}
}
}
Sunday, March 30, 2008
tasks
Points related to Upload and My Album Section
-------------------------------------------------------
1.)The Viewalbum section is now changed to show the latest added photo first for the current
selected album.
2.)The viewallphoto section is also changed to show the latest added photo first in all
photos .
3.)The upload section is now showing the basic and advanced option by using "Advance upload
Button" and "Basic Upload Button" in a more user friendly manner .
4.)In upload section Album selection/Create New and upload photo pages are merged into the single page with the help of javascript.
5) After uploading photos now user will redirect to the MyAlbums section instead of ShowUploadphoto page.
6.)View albums page has been changed to MyAlbums and now the will not show the first album's photo by default .User will have to select the album to show the photos(because default selected album creates the confusion).
7.)Now the page title of every page will change according to the user's current action e.g. if user selects an album then the page title will be changed according to the album's name dynamically .This will happen on every pages and will change with the section accordingly.
-------------------------------------------------------
1.)The Viewalbum section is now changed to show the latest added photo first for the current
selected album.
2.)The viewallphoto section is also changed to show the latest added photo first in all
photos .
3.)The upload section is now showing the basic and advanced option by using "Advance upload
Button" and "Basic Upload Button" in a more user friendly manner .
4.)In upload section Album selection/Create New and upload photo pages are merged into the single page with the help of javascript.
5) After uploading photos now user will redirect to the MyAlbums section instead of ShowUploadphoto page.
6.)View albums page has been changed to MyAlbums and now the will not show the first album's photo by default .User will have to select the album to show the photos(because default selected album creates the confusion).
7.)Now the page title of every page will change according to the user's current action e.g. if user selects an album then the page title will be changed according to the album's name dynamically .This will happen on every pages and will change with the section accordingly.
Thursday, March 27, 2008
Databas to XML
---------------------
Test.aspx page
---------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Vinit XML
-----------------------------
Test.aspx.cs
-----------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
//protected SqlConnection connect = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmdXML;
SqlDataAdapter DScmdXML ;
DataSet DSXML = new DataSet();
string sqlXML;
string sqlXML1;
int i;
int j;
string strPCode = "";
string [] arrpcode;
System.IO.StreamWriter xmlSW;
for (i = 0; i <= ListBox1.Items.Count - 1; i++)
{
if (ListBox1.Items[i].Selected) {
if (strPCode == "")
{
strPCode = ListBox1.Items[i].Text;
}
else {
strPCode = strPCode + "," + ListBox1.Items[i].Text;
}
}
}
arrpcode = strPCode.ToString().Split('\'');
for (j = 0; j <= arrpcode.Length - 1; j++) {
try {
switch ((arrpcode[j]))
{
case "Product":
//Query for selecting Albumname and Imageid using 2 tables according to albums
//sqlXML1 ="select b.AlbumName ,c.ImageID from"+
// " tblImagemaster a , tblAlbumMaster b , tblAlbumImageDetails c " +"where"
// +" a.Imageid = c.Imageid and c.AlbumId = b.AlbumId";
//Query for selecting Albumname,Imageid and Imagename using 3 tables according to albums
sqlXML1 = "select b.AlbumName ,c.ImageID ,a.Imagename from" +
" tblImagemaster a , tblAlbumMaster b , tblAlbumImageDetails c " + "where"
+ "a.Imageid = c.Imageid and c.AlbumId = b.AlbumId";
//Other test with the query check XML accordingly generated
//sqlXML1 = "select b.AlbumName ,c.ImageID from" +
// " tblAlbumMaster b , tblAlbumImageDetails c " + "where"
// + " c.AlbumId = b.AlbumId";
sqlXML = sqlXML1;
cmdXML = new SqlCommand(sqlXML, connect);
DScmdXML = new SqlDataAdapter(cmdXML);
DScmdXML.Fill(DSXML, "AlbumName");
//DataRelation dr = new DataRelation("newrelation", DSXML.Tables[0].Columns[0], DSXML.Tables[1].Columns[1]);
//dr.Nested = true;
//DSXML.Relations.Add(dr);
Response.Write("" + "Successfully Converted Table " + arrpcode[j] + " to Imagerelationnew.xml" + "");
Response.Flush();
DSXML.WriteXml(Server.MapPath("Imagerelationnew.xml"), XmlWriteMode.WriteSchema);
System.IO.StreamWriter xmlSW2 = new System.IO.StreamWriter(Server.MapPath("Imagerelationnew.xml"));
DSXML.WriteXml(xmlSW2, XmlWriteMode.WriteSchema);
xmlSW2.Flush();
xmlSW2.Close();
break;
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
Test.aspx page
---------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
-----------------------------
Test.aspx.cs
-----------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
//protected SqlConnection connect = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmdXML;
SqlDataAdapter DScmdXML ;
DataSet DSXML = new DataSet();
string sqlXML;
string sqlXML1;
int i;
int j;
string strPCode = "";
string [] arrpcode;
System.IO.StreamWriter xmlSW;
for (i = 0; i <= ListBox1.Items.Count - 1; i++)
{
if (ListBox1.Items[i].Selected) {
if (strPCode == "")
{
strPCode = ListBox1.Items[i].Text;
}
else {
strPCode = strPCode + "," + ListBox1.Items[i].Text;
}
}
}
arrpcode = strPCode.ToString().Split('\'');
for (j = 0; j <= arrpcode.Length - 1; j++) {
try {
switch ((arrpcode[j]))
{
case "Product":
//Query for selecting Albumname and Imageid using 2 tables according to albums
//sqlXML1 ="select b.AlbumName ,c.ImageID from"+
// " tblImagemaster a , tblAlbumMaster b , tblAlbumImageDetails c " +"where"
// +" a.Imageid = c.Imageid and c.AlbumId = b.AlbumId";
//Query for selecting Albumname,Imageid and Imagename using 3 tables according to albums
sqlXML1 = "select b.AlbumName ,c.ImageID ,a.Imagename from" +
" tblImagemaster a , tblAlbumMaster b , tblAlbumImageDetails c " + "where"
+ "a.Imageid = c.Imageid and c.AlbumId = b.AlbumId";
//Other test with the query check XML accordingly generated
//sqlXML1 = "select b.AlbumName ,c.ImageID from" +
// " tblAlbumMaster b , tblAlbumImageDetails c " + "where"
// + " c.AlbumId = b.AlbumId";
sqlXML = sqlXML1;
cmdXML = new SqlCommand(sqlXML, connect);
DScmdXML = new SqlDataAdapter(cmdXML);
DScmdXML.Fill(DSXML, "AlbumName");
//DataRelation dr = new DataRelation("newrelation", DSXML.Tables[0].Columns[0], DSXML.Tables[1].Columns[1]);
//dr.Nested = true;
//DSXML.Relations.Add(dr);
Response.Write("" + "Successfully Converted Table " + arrpcode[j] + " to Imagerelationnew.xml" + "");
Response.Flush();
DSXML.WriteXml(Server.MapPath("Imagerelationnew.xml"), XmlWriteMode.WriteSchema);
System.IO.StreamWriter xmlSW2 = new System.IO.StreamWriter(Server.MapPath("Imagerelationnew.xml"));
DSXML.WriteXml(xmlSW2, XmlWriteMode.WriteSchema);
xmlSW2.Flush();
xmlSW2.Close();
break;
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
Wednesday, February 13, 2008
New Links worth seeing
Hi All Techies,
Got a link to know about latest release of dotnet 3.5
http://media.wiley.com/assets/1445/39/047018759X_sample1.pdf
Also about the Microsoft's surface PC
http://www.youtube.com/watch?v=W5VUUXVdQLw
Catch you later
Vinit
Got a link to know about latest release of dotnet 3.5
http://media.wiley.com/assets/1445/39/047018759X_sample1.pdf
Also about the Microsoft's surface PC
http://www.youtube.com/watch?v=W5VUUXVdQLw
Catch you later
Vinit
Monday, February 4, 2008
A nice tecnical blog worth reading
Hi All,
Please welcome a new technical blogger who wants to make his thoughts global
Techno World.He really deserves to be highlighted as his articles are going to be very helpful to the technichal savvys.
Please welcome a new technical blogger who wants to make his thoughts global
Techno World.He really deserves to be highlighted as his articles are going to be very helpful to the technichal savvys.
Subscribe to:
Posts (Atom)