Awp (7a & 7B)
Awp (7a & 7B)
Awp (7a & 7B)
: - 7
A) Create a web application bind data in a multiline textbox by querying in another
textbox.
How to create database?
Open Database Explorer → Right Click on Data Connection → Select option ‘Add Connection’
→ In new Window, Select option Microsoft SQL Server Database File and Click on OK button
→ In New Window, Put New Database Name (TYIT) → Click on OK Button. → Click on Yes
Button.
How to create table?
After creating Database, expand your database (tyit.mdf). It will shows different folders. In that
find Tables folder and right click on that folder → select Add New Table option → from
Property tab change the table name from Table1 to sem5 and provide following column name.
Then Save the all columns name. When you expand the Tables folder, it will shows your sem5
table. Also expand sem5 table, it will shows your all columns name which you created. Then
right click on sem5 Table and select Show Table Data option. Enter following data:
Default.aspx.cs Page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string constr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\ANKITA
SHINDE\Documents\tyit.mdf;Integrated Security=True;Connect Timeout=30;User
Instance=True";
SqlConnection con = new SqlConnection(constr);
con.Open();SqlCommand cmd = new SqlCommand(TextBox1.Text, con);
SqlDataReader reader = cmd.ExecuteReader();
TextBox2.Text = "";
while (reader.Read())
{
TextBox2.Text += Environment.NewLine;
for (int i = 0; i < reader.FieldCount;i++)
{
TextBox2.Text += reader[i].ToString() + "\t";
}
}
reader.Close();
con.Close();
}
}
Output:
B)External CSS
Code:
Default.aspx Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs"
Inherits="Default3" %>
<!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 runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<asp:Label ID="Label1" runat="server" Text="Practical No. 8" Font-Size="XX-
Large"></asp:Label>
<hr />
<h1>This is External CSS Example.</h1>
<br />
<h2>B. N. Bandodkar College of of Science, Thane.</h2>
</div>
</form>
</body>
</html>
Output: