Monday, November 22, 2010

c++ instruction

1. http://www.codersource.net/c/c-tutorial-on-file-operations/c-file-i-o.aspx

2.http://www.syntax-example.com/Code/performs-file-read-write-update-473.aspx

#include <iostream.h>
#include <fstream.h>
#include <conio.h>

staticint totrec=0;    //totrec variable keep track for total variable entered//Initially Record scanned are Zerovoid main()
{
int choice;
while(1)
{
clrscr();
cout<<"Choose your choice\nNOTE : one choice for one record(except viewing data)\n";
cout<<"1) Scanning intial records\n";
cout<<"2) Appending records\n";
cout<<"3) Modifying or append records\n";
cout<<"4) Viewing records\n";
cout<<"5) Exit\n";
cout<<"Enter your choice : ";
cin>>choice;
switch (choice)
{
  case 1 :   {
         ofstream outfile;
         outfile.open("emp",ios::out);
         cout<<"\n\nPlease enter the details as per demanded\n";
         cout<<"\nEnter the name : ";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<"Enter Age : ";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<"Enter programming language known by him\her : ";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec= totrec + 1;
         outfile.close();
         }
         break;
  case 2 :   {
         ofstream outfile;
         outfile.open("emp",ios::app);
         cout<<"\n\nPlease enter the details as per demanded\n";
         cout<<"\nEnter the name : ";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<"Enter Age : ";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<"Enter programming language known by him : ";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec = totrec + 1;
         outfile.close();
         }
         break;
  case 3 :   {
         ofstream outfile;
         outfile.open("emp",ios::ate);
         cout<<"Are you interested in adding record\nenter y or n\n";
         char ans;
         cin>>ans;
         if(ans=='y' || ans=='Y')
         {
         cout<<"\n\nPlease enter the details as per demanded\n";
         cout<<"\nEnter the name : ";
         char name[20];
         cin>>name;
         outfile<<name<<endl;
         cout<<"Enter Age : ";
         int age;
         cin>>age;
         outfile<<age<<endl;
         cout<<"Enter programming language known by him : ";
         char lang[25];
         cin>>lang;
         outfile<<lang<<endl;
         totrec = totrec + 1;
         }
         outfile.close();
         }
         break;
  case 4 :   {
         ifstream infile;
         infile.open("emp",ios::in);
         constint size=80;
         char line[size];
         int counter=totrec;
         while(counter > 0)
         {
         infile.getline(line,size);
         cout<<"\n\nNAME     : "<<line<<endl;
         infile.getline(line,size);
         cout<<"AGE      : "<<line<<endl;
         infile.getline(line,size);
         cout<<"LANGUAGE : "<<line<<endl;
         counter--;
         }
         infile.close();
         }
         getch();
         break;
  case 5  :  gotoout;
  default :  cout<<"\nInvalid Choice\nTRY AGAIN\n";
  }
}
out:
}

Thursday, November 11, 2010

How To Print Part of the page in C#

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>

    <script language="javascript" type="text/javascript">
        function printPartOfPage(elementId) {
            var printContent = document.getElementById(elementId);
            var windowUrl = 'about:blank';
            var uniqueName = new Date();
            var windowName = 'Print' + uniqueName.getTime();
            var printWindow = window.open(windowUrl, windowName, 'right=50000,top=50000,width=0,height=0');
            printWindow.document.write(printContent.innerHTML);
            printWindow.document.close();
            printWindow.focus();
            printWindow.print();
            printWindow.close();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div id="MyFirstDiv" style="padding: 10 10 10 10; background-color: LightCyan; width: 300px;
            float: left;" onclick="javascript:printPartOfPage('MyFirstDiv')">
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
            Ipsum has been the industry's standard dummy text ever since the 1500s, when an
            unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting,
            remaining essentially unchanged. It was popularised in the 1960s with the release
            of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
            publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        </div>
        <div id="Div1" onclick="javascript:printPartOfPage('Div1')">
            <div style="padding: 10 10 10 10; background-color: LightCyan; width: 300px; float: left;
                margin-left: 50px;">
                Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
                Ipsum has been the industry's standard dummy text ever since the 1500s, when an
                unknown printer took a galley of type and scrambled it to make a type specimen book.
                It has survived not only five centuries, but also the leap into electronic typesetting,
                remaining essentially unchanged. It was popularised in the 1960s with the release
                of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
                publishing software like Aldus PageMaker including versions of Lorem Ipsum.
            </div>
        </div>
        <div id="Div2" style="padding: 10 10 10 10; background-color: LightCyan; width: 300px;
            float: left; margin-left: 50px;" onclick="javascript:printPartOfPage('Div2')">
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
            Ipsum has been the industry's standard dummy text ever since the 1500s, when an
            unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting,
            remaining essentially unchanged. It was popularised in the 1960s with the release
            of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
            publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        </div>
    </form>
</body>
</html>

Sunday, November 7, 2010

check

http://www.bestfreewaredownload.com/freeware/t-free-google-translate-client-freeware-mdmcdppi.html

http://www.bestfreewaredownload.com/screenshot/improve-your-english-freeware-ykltezwx.html

Tuesday, November 2, 2010

Fetch data from the database and place it in a marquee

1. First we should take the marquee tag in the source  of our web form(Page.aspx) page like this:->
<marquee direction=”up”  onmouseover=”this.start()” onmouseout=”this.stop()”
scrolldelay=”300″ style=”height: 213px”>
<asp:Literal ID=”lt1″ runat=”server”></asp:Literal></marquee>
Note:-> literal to show the database values in the marquee
2.In Database:->
My Database Name:->db2
Create a table:->
create table news1
(
id int identity(1,1),
headings varchar(50)
);
3.Page.aspx coding:->
using System.Data.SqlClient;
SqlConnection conn1 = new SqlConnection(“data source=AB\\SQLEXPRESS;initial catalog=db2;integrated security=true”);
SqlDataAdapter da1 = new SqlDataAdapter(“select * from news1″, conn1);
DataSet ds1 = new DataSet();
da1.Fill(ds1, “news1″);
string s1;
s1 = “<table><tr><td><a href=Default3.aspx style=font-family: fantasy; font-size: small; font-weight:bold; font-style: normal; color: #660066>”;
s1 += ds1.Tables["news1"].Rows[0][1].ToString();
s1 += “</a></td>”;
s1 += “<br/>”;
s1 += “<tr><td><a href=Default2.aspx style=color: #9966FF; font-weight: bold;>”;
s1 += ds1.Tables["news1"].Rows[1][1].ToString();
s1 += “</a></td></table>”;
lt1.Text = s1.ToString();


CascadingDropDown in Ajax With ASP.net

Step1: Create a table in database:-

create table test
(
 state1 varchar(50),
city varchar(50) 
)

Step2:- In the .aspx Page:-

  <select id="statelist" runat="server" onchange="showCity()" style="width: 160px">
                            <option></option>
                        </select>
                        <asp:DropDownList ID="citylist" runat="server" Width="184px">
                        </asp:DropDownList>


Take statelist for State and citylist for City 
When you select any item from statelist the citylist will automatically fill because of ajax

Step3:-  Write this in the <head> Part:-
  <script language="JavaScript" type="text/javascript" >

var xmlHttp
var arr;
function showCity()
{

xmlHttp=GetXmlHttpObject()

var url="Default.aspx"
url=url+"?name="+document.getElementById('statelist').value

xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
return false;
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
            var str;
            str = xmlHttp.responseText;
          
           arr=str.split(",");
           var i;
           for(i=0;i<arr.length;i++)
           {
               dd2= document.getElementById("citylist")
              
                var theOption = new Option;
                theOption.text = arr[i];
                theOption.value = arr[i];
                dd2.options[i] = theOption;
           }
}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
  
</script>

Step 4:-  in the .cs page:-

SqlConnection con = new SqlConnection("data source = MY\\SQLEXPRESS; initial catalog = try; integrated security=true");
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from test", con);
            SqlDataReader dr;
            dr = cmd.ExecuteReader();

            statelist.DataSource = dr;
            statelist.DataTextField = "state";
            statelist.DataBind();
            dr.Close();
            con.Close();
        }

        if (Request.QueryString["name"] != null)
        {
            string name = Request.QueryString["name"];
            Response.Clear();
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from test where state=@state", con);
            cmd.Parameters.AddWithValue("@state", name);
            SqlDataReader dr;
            dr = cmd.ExecuteReader();
            string str = "";
            int a = 0;
            while (dr.Read())
            {
                if (a == 0)
                    str += dr["city"].ToString();
                else
                    str += "," + dr["city"].ToString();

                a++;
            }
            Response.Write(str);

            Response.End();
            con.Close();

        }
    }