Friday, August 02, 2013

Save Button Code in ASP.Net

First Insert these lines at the top of code bind file

using System.Data;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;


Second step is to write this line inside your class

string _connStr = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;


Third step is to write this code in save button event


protected void btnsubmit_Click(object sender, EventArgs e)
    {
        try
        {
            String struserid, strpassword, strfirstname, strmiddlename, strlastname;
            String stremailid, strmobilenumber, strcollegename;
            struserid = txtuserid.Text;
            strpassword = txtpassword.Text;
            strfirstname = txtfirstname.Text;
            strmiddlename = txtmiddlename.Text;
            strlastname = txtlastname.Text;
            stremailid = txtemailid.Text;
            strmobilenumber = txtmobile.Text;
            strcollegename = txtcollegename.Text;
            SqlConnection con = new SqlConnection();
            con.ConnectionString = _connStr;
            String strinsert = "insert into profiledata(userid,firstname,middlename,lastname,emailid,mobile,collegename,password) values('" + struserid + "','" + strfirstname + "','" + strmiddlename + "','" + strlastname + "','" + stremailid + "','" + strmobilenumber + "','" + strcollegename + "','" + fileName + "','" + imageBytes + "','" + strpassword + "')";
            con.Open();

            SqlCommand cmd = new SqlCommand(strinsert, con);
            cmd.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception exp)
        {
            Label1.Text = "Error in inserting Data";
        }



    }

Sign In Code in ASP.Net

First Insert these lines at the top of your code bind file.

using System.Data;
using System.Configuration;
using System.Data.SqlClient;

Second step is to write this code in signin button event

protected void btnSignIn_Click(object sender, EventArgs e)
    {
        String struserid = txtuserid.Text;
        String strpassword = txtpassword.Text;
        if (struserid == "" && strpassword == "")
        {
            Label1.Text = "Please Valid User ID";
            Label2.Text = "Please Fill Valid Password";
        }
        else
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = _connStr;
            String strselect = "select userid,password from profiledata where userid='" + struserid + "' and password='" + strpassword + "'";
            con.Open();
            SqlCommand cmd = new SqlCommand(strselect,con);
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                Session["sessionuserId"] = struserid;
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('mygallary.aspx','frame1');", true);
             
            }
            else
            {
                Label1.Text = "Please Valid User ID";
                Label2.Text = "Please Fill Valid Password";
         
            }

        }
    }

Tuesday, July 30, 2013

Database Commands

Student
   
    regno
    name
    emailid
    mobile

insert into student (regno,name,emailid,mobile)values('1001','jatinder','jatinder@yahoo.com','98989898')

delete a data from a table
string selectstr="

select * from tablename where

columnname='"+variablename+"'"

delete student
string delstr="delete student where regno='"+variablename+"'";


update data into the table

string selectstr="select * from tablename where columnname='"+variablename+"'"

string strregno=regno(columns from database)
string strname=name(columns from database)
string stremailid=emailid(columns from database)
string strmobile=mobile(columns from database)

txtregno.Text= strregno;
txtname.Text= strname;
txtemailid.Text= stremailid;
txtmobile.Text= strmobile;

Update

string updatestr="update student set name='"+variablename+"',emailid='"+variablename+"',mobile='"+variablename+"'
where regno='"+variablename+"'"




displaying data in a form
   
    all records
        Reports

    specific records
   
        command

    one record
        command

string selectstr="select * from tablename"

string selectstr="select * from tablename where columnname='"+variablename+"'"

string selectstr="select * from tablename where columnname='"+variablename+"' and columnname='"+variablename+"'"

insert into student(regno,name,emailid,mobile)values('1006','jatin','jatin@yahoo.com','981409999')
insert into student(regno,name,emailid,mobile)values('1002','inder','inder@yahoo.com','981409999')
insert into student(regno,name,emailid,mobile)values('1003','tinder','tinder@yahoo.com','981409999')
insert into student(regno,name,emailid,mobile)values('1004','jati','jati@yahoo.com','981409999')
insert into student(regno,name,emailid,mobile)values('1005','der','der@yahoo.com','981409999')

update student
set mobile='9814902980',name='satinder'
where regno='1002'


select * from student

select * from student where name='jatinder' and mobile='9814902957'

delete student where name='jatinder'

Saturday, July 27, 2013

First HTML Page

<html>
 <head>
 <title>
  My First Page
 </title>
 </head>

<body bgcolor=ff6666>
<h2>About Me</h2>
<table border =1>
<tr><td><b>Name:</b></td><td> <i>Jatinder &nbsp;&nbsp;&nbsp;&nbsp;        Singh
Randhawa</i><br></td></tr>
<tr><td><b>Office Address:</b></td><td> NIIT Mall road<br></td></tr>
<tr><td><b>Phone:</b></td><td> 01832562301<br></td></tr>
<tr><td></td><td><img src="pic1.jpg" height=100 width=100/></td></tr>
</table>
<font face="Monotype Corsiva" size=10 color=red>Jatinder Randhawa</font>
<marquee behavior="alternate"><font face="Monotype Corsiva" size=10 color=red>Jatinder
Randhawa</font></marquee>

<marquee  behavior="scroll" scrollamount="1" direction="up">Your upward scrolling text goes
here</marquee>



<marquee behavior="scroll" direction="left" onmouseover="this.stop();"
onmouseout="this.start();">Go on... hover over me!</marquee>

http://www.tutorialehtml.com/en/extras/marquee.php


 </body>
</html>

Wednesday, September 26, 2012

Structure of C# Code

using System;
class ClassName
{

 Variable declaration

 Method Declaration

 public static void Main(string []args)
 {

  Create class Object
  Alocate Memory to Object
  Call Functions from the Class

 }
}

Tuesday, September 25, 2012

How to solve a program in C#.Net

First identify the Inputs of the program & also identify the requirements.

 WriteLine() is used for Output
 ReadLine() is used for Input
 Write() is used for Output

ReadLine() Function accept String data from the user


System is a namespace,which helps us to input and output data from user using different classes.

Namespace is a combination of similar type of classes

Ram basic salary is input through keyboard. His HRA is 50% of basic salary and DA is 20 % of basic salary. Calculate the gross salary?

Step 1. Input the basic salary.

Step 2. Identify the basic thinks needed for Program

 Class
 Main
 System
 Console
 WriteLine
 ReadLine


Sample Program:
using System;
class RamSalary
{
 public static void Main(string [] args)
 {
  double sal,HRA,DA,Grossal;

  Console.WriteLine("Enter Salary: ");
  sal = Convert.ToDouble(Console.ReadLine());\\10000
  HRA = sal * .5;\\5000
  DA = sal * .2;\\2000
  Grossal = sal+ HRA + DA;\\17000 = 10000 + 5000 + 2000
  Console .WriteLine("Gross Salary is : {0}",Grossal);
\\17000
 }
}

Saturday, September 22, 2012

Calling asp.net page in IFRAME, from code behind file in C#


Step 1: Write the following code in aspx file:


<IFRAME id="frame1" src="http://www.google.com"  runat="server">
         


Step 2: Write the following code in Code Behind file:

 protected void Button1_Click(object sender, EventArgs e)
{
        frame1.Attributes.Add("src", "
http://www.live.com");
}