Web Programming Paper Solution (Chapter wise)

Similar documents
ASP.NET Security. 7/26/2017 EC512 Prof. Skinner 1

ASP.NET - MANAGING STATE

Insert Data into Table using C# Code

ASP.NET Pearson Education, Inc. All rights reserved.

TRAINING GUIDE. Rebranding Lucity Web

CP3343 Computer Science Project (Year) Technical Report Document. Mr Stephen Garner

LINQ as Language Extensions

BİLGİLERİN GRIDVIEW İÇERİSİNDE EKLENMESİ, DÜZENLENMESİ VE SİLİNMESİ

ASP.NET - MULTI THREADING

Postback. ASP.NET Event Model 55

Create a cool image gallery using CSS visibility and positioning property

Document for Consuming Web-Service In.NET & JAVA

Week Date Teaching Attended 8 1/3/2010 Lab 6: Secure Connections/ Toolkit 6

Employee Attendance System module using ASP.NET (C#)

CST272 Getting Started Page 1

Further Web-Database Examples

Implementing a chat button on TECHNICAL PAPER

Caso de Estudio: Parte II. Diseño e implementación de. Integración de Sistemas. aplicaciones Web con.net

Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

LIPNET OUTBOUND API FORMS DOCUMENTATION

Web Forms ASP.NET. 2/12/2018 EC512 - Prof. Skinner 1

XML with.net: Introduction

Web based of electronic document management systems

What is XHTML? XHTML is the language used to create and organize a web page:

Chapter 2 How to develop a one-page web application

Web Services DELMIA Apriso 2017 Implementation Guide

ajax1.html 1/2 lectures/7/src/ ajax1.html 2/2 lectures/7/src/

Schenker AB. Interface documentation Map integration

Lab 4 CSS CISC1600, Spring 2012

CST272 Getting Started Page 1

Introduction to HTML5

Part A Short Answer (50 marks)

3 Customer records. Chapter 3: Customer records 57

Relaxed on the Way Towards True Validation of Compound Documents

A designers guide to creating & editing templates in EzPz

Generation of a simple web-application in the Microsoft Visual Studio 2008 with the use of Silverlight Viewer for Reporting Services 2008

ASP.NET application codes can be written in any of the following languages:

CSC309 Midterm Exam Summer 2007


blink.html 1/1 lectures/6/src/ form.html 1/1 lectures/6/src/

Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

Creating A Web Page. Computer Concepts I and II. Sue Norris

ASP.NET 2.0 FileUpload Server Control

CS134 Web Site Design & Development. Quiz1

COPYRIGHTED MATERIAL. AJAX Technologies. Google Suggest

I Can t Believe It s Not

CMT111-01/M1: HTML & Dreamweaver. Creating an HTML Document

8 Library loan system

<asp:requiredfieldvalidator ID="RequiredFieldValidator2" runat="server"

3-tier Architecture Step by step Exercises Hans-Petter Halvorsen

Computer Science E-1. Understanding Computers and the Internet. Lecture 10: Website Development Wednesday, 29 November 2006

INTRANET. EXTRANET. PORTAL.

STEP 1: CREATING THE DATABASE

Controls are also used for structural jobs, like validation, data access, security, creating master pages, data manipulation.

Using netbeans create a new Web Application and select the framework as JSF 2.2

Unit Notes. ICAWEB411A Produce basic client-side script for dynamic web pages Topic 1 Introduction to JavaScript

private void closetoolstripmenuitem_click(object sender, EventArgs e) { this.close(); }

Câu 1: (2 điểm) So sách giữa 2 đối tượng Response và Request. Cho ví dụ minh hoạ.

Web Development & Design Foundations with XHTML. Chapter 2 Key Concepts

Wed 02 Nov :01:06 AM EST modpow.html

HTML: The Basics & Block Elements

ASP.NET Using C# Student Guide Revision 2.2. Object Innovations Course 416

User Guide for Direct Post Method JavaScript Relay URL Redirect

JSF - H:INPUTSECRET. Class name of a validator that s created and attached to a component

map1.html 1/1 lectures/8/src/

Wireframe :: tistory wireframe tistory.

OFBiz Content Management How to

What You Need to Use this Book

CHANGE is not a four-letter word. Kimberly

CSCI DBMS Spring 2017 Final Examination. Last Name: First Name: Student Id:

Cloud Computing. Up until now

MVC :: Understanding Views, View Data, and HTML Helpers

Session 24. Introduction to Java Server Faces (JSF) Robert Kelly, Reading.

In the previous chapter we created a web site with images programmed into HTML page code using commands such as: <img src="images/train.

Basics of Page Format

JSF - H:PANELGRID. JSF Tag. Rendered Output. Tag Attributes. The h:panel tag renders an HTML "table" element. Attribute & Description.

Micronet International College

Dreamweaver: Portfolio Site

LAMPIRAN. Universitas Sumatera Utara

ASP.net. Microsoft. Getting Started with. protected void Page_Load(object sender, EventArgs e) { productsdatatable = new DataTable();

HTML Overview. With an emphasis on XHTML

Module 2: Using Master Pages

Security: Threats and Countermeasures. Stanley Tan Academic Program Manager Microsoft Singapore

The Processing Directives of a Page p. 91 The Page Class p. 99 Properties of the Page Class p. 100 Methods of the Page Class p.

Wicket and Aida/Web Brief Comparison

What is ASP.NET? ASP.NET 2.0

CSCI 5333 DBMS Fall 2017 Final Examination. Last Name: First Name: Student Id:

Chapter 2:- Introduction to XHTML. Compiled By:- Sanjay Patel Assistant Professor, SVBIT.

This PDF was generated in real-time using DynamicPDF; Generator for.net.

ASP.NET with C# LAB Manual

Date Issued: Subject: Editing the HTML files in the C-more panel. Revision: Original

TS: Microsoft.NET Framework 3.5, Windows Forms Application Development

First, create a web page with a submit button on it (remember from creating forms in html?):

Webnodes Developers Manual

Web Publishing Basics I

XML. Technical Talk. by Svetlana Slavova. CMPT 842, Feb

Internet publishing HTML (XHTML) language. Petr Zámostný room: A-72a phone.:

Web Forms for Marketers 8.0 Rev: September 13, Web Forms for Marketers 8.0

home.php 1/1 lectures/6/src/ include.php 1/1 lectures/6/src/

Header. Report Section. Footer

Transcription:

.Net.net code to insert new record in database using C#. Database name: College.accdb Table name: students Table structure: std_id number std_name text std_age number Table content (before insert): 2 abcd 21 <%@ Page Language="C#" %> <%@ Import namespace="system.data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <script runat="server"> protected void btn_insert_click(object sender, EventArgs e) OleDbConnection cn; OleDbCommand cm; String query; cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Kashif\Documents\college.accdb"); query = "insert into students values(" + std_id.text + ",'" + std_name.text + "'," + std_age.text + ")"; cm = new OleDbCommand(query, cn); try cn.open(); cm.executenonquery(); catch (OleDbException ex) Response.Write("Error: " + ex.message); finally if (cn.state == ConnectionState.Open) cn.close(); std_name.text = ""; Page 1 of 10

std_age.text = ""; std_id.text = ""; </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>dynamic data entry using ASP.net and ADO.net</title> </head> <body> <form id="form1" runat="server"> <div> New Student entry student id: <asp:textbox ID="std_id" runat="server"></asp:textbox> student name: <asp:textbox ID="std_name" runat="server"></asp:textbox> age: <asp:textbox ID="std_age" runat="server"></asp:textbox> <asp:button ID="btn_insert" runat="server" Text="Insert" onclick="btn_insert_click" /> </div> </form> </body> </html> Table content (after insert): std_id=1, std_name=xyz, std_age=20 1 xyz 20 2 abcd 21 Page 2 of 10

.net code to delete record in database using C#. Database name: College.accdb Table name: students Table structure: std_id number std_name text std_age number Table content (before delete): 2 abcd 21 <%@ Page Language="C#" %> <%@ Import namespace="system.data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <script runat="server"> protected void btn_del_click(object sender, EventArgs e) OleDbConnection cn; OleDbCommand cm; String query; cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Kashif\Documents\college.accdb"); query = "delete from students where std_id=" + del_id.text; cm = new OleDbCommand(query, cn); try cn.open(); cm.executenonquery(); catch (OleDbException ex) Response.Write("Error: " + ex.message); finally if (cn.state == ConnectionState.Open) cn.close(); del_id.text = ""; Page 3 of 10

</script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>dynamic data entry using ASP.net and ADO.net</title> </head> <body> <form id="form1" runat="server"> <div> Delete Student Student id: <asp:textbox ID="del_id" runat="server"></asp:textbox> <asp:button ID="btn_del" runat="server" Text="Delete" onclick="btn_del_click" /> </div> </form> </body> </html> Table content (after delete): std_id=2 Page 4 of 10

.net code to update record in database using C#. Database name: College.accdb Table name: students Table structure: std_id number std_name text std_age number Table content (before update): 2 Abc 21 <%@ Page Language="C#" %> <%@ Import namespace="system.data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <script runat="server"> protected void btn_update_click(object sender, EventArgs e) OleDbConnection cn; OleDbCommand cm; String query; cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Kashif\Documents\college.accdb"); query = "update students set std_name=?, std_age=? where std_id=?"; cm = new OleDbCommand(query, cn); try cm.parameters.add(new OleDbParameter("std_name",update_name.Text)); cm.parameters.add(new OleDbParameter("std_age",update_age.Text)); cm.parameters.add(new OleDbParameter("std_id",update_id.Text)); cn.open(); cm.executenonquery(); catch (OleDbException ex) Response.Write("Error: " + ex.message); finally Page 5 of 10

if (cn.state == ConnectionState.Open) cn.close(); update_name.text = ""; update_age.text = ""; update_id.text = ""; </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>dynamic data entry using ASP.net and ADO.net</title> </head> <body> <form id="form1" runat="server"> <div> Update Student Student id: <asp:textbox ID="update_id" runat="server"></asp:textbox> Student name: <asp:textbox ID="update_name" runat="server"></asp:textbox> age: <asp:textbox ID="update_age" runat="server"></asp:textbox> <asp:button ID="btn_update" runat="server" onclick="btn_update_click" Text="Update" /> </div> </form> </body> </html> Table content (after update): std_id=2, std_name=abcd, std_age=20 2 abcd 20 Page 6 of 10

.net code to view records in tabular format from database using C#. Database name: College.accdb Table name: students Table structure: std_id number std_name text std_age number <%@ Page Language="C#" %> <%@ Import namespace="system.data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <script runat="server"> protected void btn_view_click(object sender, EventArgs e) OleDbConnection cn; OleDbCommand cm; String query; OleDbDataReader reader; cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Kashif\Documents\college.accdb"); query = "select * from students"; cm = new OleDbCommand(query, cn); try cn.open(); reader = cm.executereader(); Response.Write("<table border='1'>"); Response.Write("<tr><th>ID</th><th>Name</th><th>Age</th></tr>"); while(reader.read()) Response.Write("<tr>"); Response.Write("<td>"+reader["std_id"]+"</td>"); Response.Write("<td>" + reader["std_name"] + "</td>"); Response.Write("<td>" + reader["std_age"] + "</td>"); Response.Write("</tr>"); Response.Write("</table>"); catch (OleDbException ex) Response.Write("Error: " + ex.message); Page 7 of 10

finally if (cn.state == ConnectionState.Open) cn.close(); </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>dynamic data entry using ASP.net and ADO.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:button ID="btn_view" runat="server" Text="View Records" onclick="btn_view_click" /> </div> </form> </body> </html> 2 abcd 20 Page 8 of 10

Life cycle of ASP.net application. ASP.Net life cycle specifies, how: ASP.Net processes pages to produce dynamic output The application and its pages are instantiated and processed ASP.Net compiles the pages dynamically The ASP.Net life cycle could be divided into two groups: Application Life Cycle Page Life Cycle The application life cycle has the following stages: 1. User makes a request for accessing application resource, a page. Browser sends this request to the web server. 2. A unified pipeline receives the first request and the following events take place: 1. An object of the ApplicationManager class is created. 2. An object of the HostingEnvironment class is created to provide information regarding the resources. 3. Top level items in the application are compiled. 3. Response objects are created. the application objects: HttpContext, HttpRequest and HttpResponse are created and initialized. 4. An instance of the HttpApplication object is created and assigned to the request. The request is processed by the HttpApplication class. Different events are raised by this class for processing the request. Page 9 of 10

ASP.net code to display today s date and time. <%@ Page Language="C#" %> <!DOCTYPE html /> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>show Date & Time</title> </head> <body> <% Response.Write(DateTime.Now); %> </body> </html> 5/8/2016 11:10:39 AM Page 10 of 10