-->

Friday, May 15, 2015

How to create cookies in asp.net c#

If you want to create individual item cookie then use HttpCookie class , which is available in System.Web namespace. There are two object to use get and set cookie in the computer that are Request and Response. By using Request object  we can get the cookie from the computer and By using Response object we can create new cookie in the computer.

Create cookie for individual item:

HttpCookie cookie = new HttpCookie("mycookie");
        cookie.Value = "Hello World";
        cookie.Expires = DateTime.Now.AddMinutes(10d);
        Response.Cookies.Add(cookie);

Here,

  • cookie is the instance of HttpCookie class, By using this we can invoke properties of this class.
  • mycookie is a name of  the cookie.
  • This cookie will expired just after 10 minute.
  • Add new cookie by the Response object. 
Retrieve cookie which is stored in computer

     HttpCookie cookie =Request.Cookies.Get("mycookie");
        Response.Write(cookie.Value.ToString());

Create cookie for multiple item :

 Response.Cookies["username"].Value = "Jacob";
        Response.Cookies["username"].Expires = DateTime.Now.AddMinutes(10d);
        Response.Cookies["password"].Value = "Lefore";
        Response.Cookies["password"].Expires = DateTime.Now.AddMinutes(10d); 

Retrieve multiple cookie item:

  HttpCookieCollection cookies = Request.Cookies;
        for (int i = 0; i < cookies.Count; i++)
        {
            Response.Write(cookies[i].Name.ToString() + "<br/>");
            Response.Write(cookies[i].Value.ToString() + "<br/>");
        }

Code generate the following output

How to create cookies in asp.net c#

How to load multiple data table in DataSet

ASP.NET C# : Load multiple data table in DataSet. If you want to add multiple table in DataSet then need two SqlDataAdapter for DataSet.
Source code :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    </div>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add multiple table in dataSet" />
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
        <br />
        <asp:GridView ID="GridView2" runat="server"></asp:GridView>
    </form>
</body>
</html>

Code Behind Code

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        con.Open();

        SqlDataAdapter productadapter = new SqlDataAdapter();
        productadapter.TableMappings.Add("Table", "Suppliers");
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "Select * from [Suppliers]";
        cmd.Connection = con;
        productadapter.SelectCommand = cmd;
        DataSet ds = new DataSet();
        productadapter.Fill(ds);

        SqlDataAdapter adapter = new SqlDataAdapter();
     adapter.TableMappings.Add("Table", "Products");
        SqlCommand cmd1 = new SqlCommand();
        cmd1.CommandText = "Select * from [Products]";
        cmd1.Connection = con;
        adapter.SelectCommand = cmd1;
     
        adapter.Fill(ds);

        con.Close();

        GridView1.DataSource = ds.Tables["Products"];
        GridView1.DataBind();

        GridView2.DataSource = ds.Tables["Suppliers"];
        GridView2.DataBind();




    }
}
Code Generate the following output


How to load multiple data table in DataSet

Thursday, May 14, 2015

Hyperlink field Example of ASP.NET Grid View

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="JobId" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="JobId" HeaderText="JobId" InsertVisible="False" ReadOnly="True" SortExpression="JobId" />
                <asp:BoundField DataField="JobName" HeaderText="JobName" SortExpression="JobName" />
                <asp:BoundField DataField="AboutJob" HeaderText="AboutJob" SortExpression="AboutJob" />
                <asp:BoundField DataField="Salary" HeaderText="Salary" SortExpression="Salary" />
                <asp:HyperLinkField DataNavigateUrlFields="JobId" DataNavigateUrlFormatString="Default2.aspx?JobId={0}" HeaderText="Click to view " Text="details" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [JobId], [JobName], [AboutJob], [Salary] FROM [AddJob]"></asp:SqlDataSource>
   
    </div>
        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="JobId" DataSourceID="SqlDataSource2">
            <Columns>
                <asp:BoundField DataField="JobId" HeaderText="JobId" InsertVisible="False" ReadOnly="True" SortExpression="JobId" />
                <asp:BoundField DataField="JobName" HeaderText="JobName" SortExpression="JobName" />
                <asp:BoundField DataField="AboutJob" HeaderText="AboutJob" SortExpression="AboutJob" />
                <asp:BoundField DataField="Experience" HeaderText="Experience" SortExpression="Experience" />
                <asp:BoundField DataField="Qualification" HeaderText="Qualification" SortExpression="Qualification" />
                <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
                <asp:BoundField DataField="FunctionalArea" HeaderText="FunctionalArea" SortExpression="FunctionalArea" />
                <asp:BoundField DataField="Salary" HeaderText="Salary" SortExpression="Salary" />
                <asp:BoundField DataField="Contact_person" HeaderText="Contact_person" SortExpression="Contact_person" />
                <asp:BoundField DataField="Contact_Person_Numer" HeaderText="Contact_Person_Numer" SortExpression="Contact_Person_Numer">
                <ControlStyle Width="10px" />
                <ItemStyle Width="50px" />
                </asp:BoundField>
                <asp:BoundField DataField="Email_id" HeaderText="Email_id" SortExpression="Email_id" />
                <asp:BoundField DataField="Work" HeaderText="Work" SortExpression="Work" />
                <asp:BoundField DataField="company_name" HeaderText="company_name" SortExpression="company_name" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [AddJob] WHERE ([JobId] = @JobId)">
            <SelectParameters>
                <asp:QueryStringParameter Name="JobId" QueryStringField="JobId" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </form>
</body>
</html>

Code generate the following output

Hyperlink field  Example of ASP.NET Grid View


Wednesday, May 13, 2015

Implementation details of online examination system in asp.net c#

According to my ASP.NET online examination project there are following implementation details, these are:
5.1 Implementation

Implementation of the project is the topics illustrated in the design prototype and the requirements stated in the analyses section.  In order to better illustrate what has been done pictorially, some screen shots illustrations will be presented. On the other hand related data utilizations in the project have been implemented  using   SQL Server 2008  for  data  storage  and  data  retrieval  purposes  for  database interfaces.
5.1.1 Screen implementation
Home page:
The  project  starts  with  an  initial  application  screen  of  "home  page"  where  main  menu  bar  and welcoming page is illustrated.

home  page

Login and registration:
Any user can view basic information on the site with an exception of utilization of the site but authenticated user can give the exam by the examination panel. First of all admin should register the student name in database. After successfully registration a student can login into the examination panel.

registration page of online examination system



During the registration we should always remember that email and name is the primary key so do not enter duplicate values in the database.

Candidate login page

 In the login page there are two types of information required to be selected or filled in; Email and user password. The Email and the password are defined by user with specified criteria. The restricted criterion is on the email which requires “@” symbol in between mail id. If wrong entry is typed then user will be alerted as "bad entry" message and then redirected to the registration page.  If all proper information entered then LOGIN can be submitted or CANCELED.


Examination panel:

 A registered student can give the exam by the examination panel. Before the exam, candidate have to select the subject name by the popup menu. In this project we have to provide 4 subject like GK,c++,Java and c#. Each subject contain 5 questions.  In The examination panel student can view one question at a time.  He/she faced total 5 question during the given time, if we applied the system in real time then all registered user can view different questions because questions appeared on the screen randomly.

 


Now, the above mentioned snap is related to subject which is selected by the candidate. After selected candidate can view the exam panel that is mentioned in the below snap.

exam panel


5.2 Description of the Application


5.2.1 System architecture:

In this application Client-Server architecture was used. In these architecture two computers programs interact with each other.One program is called client which makes a request from Server, and the other one is called as Server which provides response to the request. There is also a database which interacts with Server. ASP and database technology are used at server side, and html and cookies are used at the client side.

5.2.2 Software application used in the website
ASP: It has the server side script such as database connection and the session. ASP was used for database  connection, creating session, login and registration forms and some other pages. Mostly all pages are functioning with ASP, because they interact with database and server and that makes our site a dynamic website. It takes some information from forms to server, and some data from database to client, or it passes the values among pages.

IIS: Internet Information Services for Windows is used to host the website. It hosts the website locally under inetpub and root directory First, Windows 7 or  IIS was set up to host the online examination system website.


HTML/SHTML: It is a markup language that is used to describe web pages. In online examination system website html pages were used. To avoid repetition #include file was created for footer and header, and html pages were saved as shtml.


CSS: It defines the way how html pages are to be displayed. In online examination system website styles are saved in external .css file which makes it easy to change the appearance and the layout of all the pages just by editing one file.


SQL Server:  SQL Server  is the famous tool for creating database for large applications. In online examination system, it was used to create the tables such as questions, register, subject and etc


SQL: It is used to access and communicate with database server by manipulating the data.

PHOTOSHOP: For creating logo Adobe's famous tool Photoshop was used.




5.3 Hardware requirements

Hardware requirements of the implemented project can be classified under two terms. There would be back-end requirements which are publication of the online website from a server. The other important aspect  is  the  implementation  of  the  RDBMS  database  implementation.  In  our  case,  the  required database was SQL Server. Each design schema was converted into database table form through


Access. There was not much of hardware requirements to implement the project, it is a simply as having a web server to publish the project online. On the other hand, for the front-end end user purposes, they only need to have a system up-to-date internet connection with any proper browser to be able to do their transactions online. The required system is a Three-Tier Architecture. In this architecture, the data is stored onto a server is in interaction with end-users with a unit called client. So, this project hardware architecture is based on two-tier client-server based architecture.


Wednesday, May 6, 2015

Demerits of bottom-up technique in c language

In my previous article i explained about:

  1. Features of top-down technique
  2. Merits of bottom-up technique
Now, today i will learn about Bottom up technique demerits:

  • The application developed using this technique cannot be tested as a whole before the development of main solution.
  • The sub-solutions are added or linked to the main solution without knowing the details of its coding.
  • The design of the sub-solutions are coded without the idea of their linking in the main solution.
  • The integration testing may cause complications because it is done in the later stage of application development.
You may also learn about : Top Down Technique

Friday, May 1, 2015

fseek( ) method in C language

In order to access the file directly the file handling function fseek( ) is used. Access is nothing but to seek. So, it is easy to remember the function for direct access. The syntax of the function fseek( ) is as follows:

int fseek( FILE *fp, long offset, int whence)

Where:
fp is the file pointer
offset is the number of bytes to skip
whence can be replaced with SEEK_SET- from beginning
                                                SEEK_CUR- from current position
                                                SEEK_END - from the end
This position repositions the file or record pointer from the whence position by offset bytes on the file stream fp. The function returns 0 on success or non-zero on unsuccessful.

The following program gives the idea of using the fseek( ) function.

/* Program to display the details of the students using fseek( ) in the binary file "studb.dat" */

#include<stdio.h>
#include<conio.h>
#include<process.h>
main ( )
{
struct Stud
{
int rollno, marks[5];
char fname[25];
float avg;
};
typedef struct Stud STUDENT ; /* renaming the data type struct Stud to Student */
int idx;
FILE *fp;
STUDENT s; /* s is the structure variable to read/write student's data */
fp = fopen("studb.dat","rb"); /* Read mode to scan the records from the binary file "studb.dat" */
if(fp == NULL)
{
printf("File opening error....");
exit(1);
}
clrscr( );       /* To clear the screen and to display heading */
printf("%4s%27s","RNo","FName");
printf("%7s%7s%7s%7s%7s","Marks1","Marks2","Marks3","Marks4","Marks5");
printf("%9s\n\n","Avg");
fseek(fp,2*sizeof(s),SEEK_CUR);  /* to remove to 3rd record */
fread(&s,sizeof(s),1,fp);  /* to read 3rd record directly */
if(feof(fp))
exit(1);  /* To come out of the loop, at the end of the file */
printf("%4d %26s",s.rollno,s.fname); /* Data is displayed on the screen */
for(idx=0;idx<5;idx++)
printf("%6d",s.marks[idx]);   /* Next set of Data is displayed */
printf("%8.2f \n",s.avg);  /* Avg is displayed and new line generated for the next record */
fclose(fp);
}

Online job website project in asp.net c#

Introduction

Online Job website site provide the functionality to search new jobs online according to candidates eligibility in various fields. This web site helps to find new recruits in governmental and private sector day by day with latest openings. This site is also very helpful for freshers to find job because on this site, we are specially working to meet new recruiter and candidates as per their requirements.


Project description:

When we open the project first time in the browser, home page appeared which is contain lots of things like Header part, Navigation bar, body part and last one is footer part.

Online job weebsite project in asp.net c#


A header part of the project contains: (According to above mentioned snap)

  • Welcome message for both guest and authenticated user.
  • Sign-In and Signup options
Now come to navigation part, its contain : (According to above mentioned snap)
  • Home page links 
  • Search jobs via Job Name, salary wise, etc.
  • Employer Zone
  • Contact us page
  • Feed Back System
Now, click to any letters which is mentioned in the search job option. After that you will see a table, in which we have JobId, JobName, and Salary.

Download 

mail me  : narenkumar851@gmail.com


© Copyright 2013 Computer Programming | All Right Reserved