Web Application Development (Dot Net)


Web Application Development

Topics : 

01. Dotnet Development Area
02. Page Creation concept
03. Types of Page in dotnet
04. Page Identification in dotnet
05. Server identification - imp
06. Directory identification - imp
07. URL format – most imp
08. How to create first web Application in dotnet framework
09. Dot net Environment
10. How to create first webpage in dotnet
11. Dotnet support which type of coding
12. How to clear control
13. How to set cursor in a control
14. Dot net color library drawing
15. Dot Net Navigation
        15.1 Using Control
        15.2 Navigation using code
                15.2.1 Redirect method
                15.2.2 Transfer method
16. Date and Time Concept
17. Content management in dotnet - imp
18. Property of Multiview
19. Dropdown list control
20. How to insert in dropdown list
22. State Management/ Data transfer - imp
        22.1 Session
        22.2 Query String
        22.3 Application State
        22.4 View State
        22.5 Cookies
23. File Uploading
        23.1 Types of file
        23.2 File property
        23.3 File Upload Control
24. Master Page - imp
25. Validation
        25.1 Client side Validation
        25.2 Server Side Validation
26. Class and Object (Dot Net Framework) – most imp
27. Database Connectivity – most imp
28. Database Management Using C#
        28.1 Parameterized Method
29. Data Bound Control – imp
30. Handling Scaler Function in Database Connectivity – imp
31. Connection String Management
32. Data Control (Machine Test Topic) – imp
        32.1 Grid View
            A. Grid View Footer
            B. How to insert control inside grid view – imp
            C. Grid View Event handling
            D. Grid View Auto Generate Column
            E. How to bind image in a grid view control
            F. Grid View Event Handling (Inside the control - naming container)crud operation - imp
            G. Dynamic Binding (Control) -imp
            H. How to use single template field in a grid view control
            I. Grid View Paging Concept

        32.2 Repeater
            A. Repeater Event handling
            B. How to activate command name
            C. How to Find Control Inside the Repeater(Inside If Condition)
            D. How to perform event handling outside the control

        32.3 Data List Control
            A. Attributes of Data List Control
            B. Event Handling in data List Control

        32.4 Form view Control
            A. Form View Event Handling

        32.5 List View Control 
        32.6 Detail View control

33. Store Procedure Connectivity Inside aspx page
34. Data Tables
35. 3Tier Architecture
36. Access html textbox inside button event
37. Display empty gridview
38. Email programming
39. How to display calendar
40. Ajax configuration
41. Grid view RowDatabound event
42. Random number Concept
43. How to Create Dynamic Directory(Runtime)
            

2017
File > new > project > visual C#> asp.net(webapp) > ok > select empty option


2022 & 2019
File > new > project > asp.net WebApplication(dotnet Framework) > create > Empty then ok



1. Dotnet Development Area

1. Design area – aspx(active server page extended)
2. Source Area – automatically created(html formate)
3. Code Area – using c# language (.cs)



2. Page Creation concept

3. Types of Page in dotnet

    - There are two types of page in dot net app

3.1. Design page
3.2. Code page

Ex.
    Registration.aspx
    Registration.cs

Ex
    About.aspx
    About.aspx.cs


4. Page Identification in dotnet

    Html – index.html
    Java – index.js
    Python – index/home.py
    PHP - index
    .net – default.aspx




5. Server identification - imp


1. Linux Server : support html,java,python
2. Window Server : supports .net window server
3. Cloud server : support all


6. Directory identification - imp

POST(power on self test) : first step of computer system

1. Linux Server
    Starting Directory : www

2. window Server
    Starting Directory : httpdocs



7. URL format – most imp

http://abc.com

( : ) colon is server finder operater
( / ) is called root directory finder(www,httpdocs)
(second / ) slash is application directory finder
Abc.com is called domain

http:/httpdocs/college/erp.com

condition looping function input output concept



6-12-2023

8. How to create first web Application in dotnet framework

9. Dot net Environment
    - Solution explorer represent all file, directories,library,audio,video resources
    - Server explorer representing all database activities
    - Toolbox represent all control (textbox , listbox, etc)
    - Property window – represent all attribute (height, width, color etc)


10. How to create first webpage in dotnet
    - in dotnet framework we have to use webform
    - All application is developed inside root directory – imp

Go to solution explorer > select root (Webapplication1) > select project menu > add new item > select visual c# > select web form

Arrow > is called expendable symbol


Event programming

11. Dotnet support which type of coding
    - Dot net support all types of procedural coding
    - Programming language is use to functional coding



All types of numerical result decimal , without decimal stored in a control is use to toString() method

12. How to clear control

 (  “”  )

TextBox1.text = “”;
TextBox2.Text =””;


13. How to set cursor in a control

//set cursor in a control
TextBox1.focus();
Cursor is called focus


14. Dot net color library drawing

    - Number of colors support in C programming language
        16 color
    - Dot net support 256 and above colors

//set background color
TextBox3.backcolor= System.Drawing.Color.Red;



Task 1
Create a web form
Center of the screen – student admission
Enter Roll no. – tb
Enter name – tb
Email – tb
Mobile – tb
Subject – tb
Branch – tb
M1 – tb
.
.
M5 – tb
Total – tb
Grade – tb
Button submit
Button Message

Logic
1. Input all record cumpolsory
2. Calculate total if all subject mark greater than 40
3. Display grade() in following cond
Total > 250
Display A grade
Total > 150 && total < 250 b grade
Otherwise fail
If user can click messege button then display message in following formate
Dear student ,
Name –
Subject –
Total –
Grade-
Thanks for visit my website (Red Color)


07-12-2023

15. DotNet Nevigation

15.1 Using control
15.2 Using Code

15.1 Using Controll
    - Link button control – property : text,postbackurl
    - Hyperlink control – property : text,navigateurl
    - Image button control – property : imageurl,postbackurl

Default.aspx


Default.aspx.cs



Website working methodology
    - Website is work postback method


~/About.aspx
~/    : root directory finder
Web1/about.aspx

Link Button using Attribute

15.2 Navigation using code
There are two method is use to navigate one page to another page
    15.2.1. Redirect method
    15.2.2. Transfer method

15.2.1 Redirect method
- Display next page name(only name)
- //visit next page
- Response.Redirect("About.aspx");


15.2.2 Transfer method
- In this method user can visit next page but display previous page name(url)
//navigation using transfer
Server.Transfer("Contact.aspx");


16. Date and Time Concept
In dotnet framework is basically is to manage all date and time concept using datetime library


//display current date and time
label1.Text = DateTime.Now.ToString();

//display only date
label2.Text = DateTime.Now.ToString("dd/MM/yyyy");

//display only month
label3.Text = DateTime.Now.ToString("MM");

//display only year
label3.Text = DateTime.Now.ToString("yyyy");

//how to increase month
label1.Text = DateTime.Now.AddMonths(2).ToString("MMM");

//increase days
label1.Text = DateTime.Now.AddDays(7).ToString("dd");

//add years
label1.Text = DateTime.Now.AddYears(2).ToString("yyyy");



Assignment 1
create a form login.aspx
enter username – tb
enter date – tb
Button – check validity
Logic 1
1. Input date from the use
2. Match user date to current date
3. If it is match then display valid use(label controll)
4. Iotherwise display invalid user
5. If user is valid then open contact.aspx page
6. Input all record compulsory
Search (how to use alert statement inside response.write())


17. Content management in dotnet - imp
    - Content management in dot net is basically is to a specific control Multiview control
    - Multiview is based on array method
    - Inside the Multiview control we have to use view control

    View 1 – 0
    View 2 – 1
    View 3- 2
    View 4 – 3



18. Property of Multiview
    - Active view index


Multiview.aspx

Multiview.aspx.cs




Assignment
Create layer level registration concept
Create a page - registration.aspx
Center of the screen – student registration form
Create Multiview control in following operation
View 1
Center of the screen – basic information
Name – tb
City – tb
Clg – tb
Email – tb
Mobile – tb
Button- next to continue
Logic if use press next to continue btn then open view 2
View 2
Center of the screen - qualification detail
Student name – lable (automatically display)
College – lbl – (AD)
Branch – tb
Semester – tb
Subject – tb
Button – next to continue
Logic
If user press next to continue button then open view 3
Center of the screen – Mark Allotment
Student name – lable (automatic)
College – lbl – auto
Branch – lbl – ad
Mark1 – tb
Mark 2 – tb
Mark 3 – tb
Mark 4 – tb
Mark 5 – tb
Button – next to continue
If user press button above
Then calculate
1. Total
2. Grade
If user press next to continue button then open view 4 where display student mark report
View 4
Center of the screen – Mark report
Student name – lbl (ad)
Email – lbl
Mobile – lbl
Branch – lbl
Subject – lbl
Total – lbl
Grade – lbl
Button – finish
If user press finish then display thanks messege to view 5
View 5
Dear student – lbl
Draft message – display all data automatically



08-12-2023

19. Dropdown list controll

List – collection of dataitem
Event – index change
Index = 0
Based – Array
Arrow is called mastertag
Mastertag – inbuild property


20. How to insert in dropdown list

20.1 Using design method
20.2 Code Method

    - Click mastertag – edit item
    - Items is called Array
    - Property of dropdown list – Autopostback(by default false)
    - In case of coding autopostback = true
    - Jis control me data dikhana/show karna hai vo pahle likhte hai

How to match dropdown data
How to clear dropdown element
How to insert data element using code
How to display number of count in a dropdown list
How to use insert method

DropDownDemo.aspx


DropDownDemo.aspx.cs




Ass 1
Select Degree – dropdown list(UG,PG)
Your branch is – dropdown list
Logic
If user select ug then display all ug branches in dropdown list
Cse , it, etc, etrx, mech
If user select pg then display all pg branches in dropdown list2
Mca,mba,mtech


Assignment 2
Create a form – Demo.aspx
Select country - dropdownlist1(India,US,Australia)
Select state – dropdownlist2
Select city – dropdownlist3
Logic
1 if user select india in dropdownlist1 then display all state in dropdownlist2 otherwise display state not available
2 if user can select specific state (dropdown2) then display a particular city(dropdown)



Ass 3
Create a form – calculation.aspx
Enter First Number – tb
Enter Sec Number – tb
Select operation – dropdown list(ADD,Multi,Substract) fixed
Result is – tb
Logic
1. If user select add operation in a dropdown list then display addition result (result tb)
2. Form is to be design a particular css


21. Radio Button list Controll -imp
1. Single selection at time
2. Similar to dropdown list control



22. State Management/ Data transfer - imp
    - State management is a concept for transferring data between one page to an other page
    - There are following state management concept used in dotnet framework

    1. Session
    2. QueryString
    3. Viewstate
    4. Applicationstate
    5. Cookies

22.1 Session
    - session is a state management concept
    - Which type of data transfer in session – private
    - session is use to private data transfer (secured data transfer)
    - timelimit – 60sec (bydefault)
    - working methodology – IIS
    - Session cannot display data in web url – imp


How to create Session
Note = session is to be create inside the event

Syntax
    Session [“variable”] = value;
Ex.
    Session [“email”] = “abc@gmail.com”;
    Session[“email”] = TextBox1.text;





How to Access Session
- Session is to be Access inside the page load event in form of string

Syntax
    Control = (string) Session[“variable”];
Ex.
    Label1.text = (string) Session["email”];



How to create multiple session


Ass 4
Create a page
(registration.aspx)
Center of the screen – registration form
Name : tb
Email : tb
Mobile : tb
Password : tb
Date of Registration : tb -Automatic display current display(pageload)
Button – login(visit login.aspx)
Logic 1
1. Transfer all the information to login page using session
2. Login.aspx page
Design
Enter Email id : tb
Enter password : tb
Button – text exam – Exam.aspx
Logic
1. Match using email and password with session data vale
2. If match the open exam.aspx page
3. Otherwise display exam.aspx
Exam.aspx page
Name – tb (automatic)
Email – tb (automatic)
Mobile - tb (automatic)
Select Your Branch – Dropdownlist
(cse,it,etc,etrx)- fixed
Select semester – dropdown list(1 to 8)
Select your shift - dropdown list (morning, evening)
Button – Generate exam(generateexam.aspx)
Generateexam.aspx
Name – tb(automatic)
Email – tb
Branch – tb
Semester – tb
Que : -
Q1 - option
Q2 – option
Total 10 question
Button – Scorecard(score.aspx)
Using css
Student name ;
Email
Branch
Semester’
Total score
Grade
If score is > 8 – A grade
Scrore > 6 && < 8 – Bgrade
Otherwise fail

Update panel
Cannot relaoading the page(try)

22.2 Query String
    - It is called state management system
    - Query string is use to display data in web url
    - Session separator [] square bracket
    - Query string separator is use to ? operator
    - Query string is to be create inside the event


How to create Query string

Syntax :
    Response.Redirect(“pagename.aspx?variable=”+conrolname);
Ex
    Response.Redirect(“page2.aspx?email=”+TextBox1.Text);

How to display query string data in a webpage

    Controll = Request.Querystring[“variable”]



Imple

    Label.Text = Request.Querystring[“email”];



How to create multiple querystring

- Create multiple querystring - using & symbol

Syntax :
Response.Redirect(“pagename.aspx?variable”+controllname + “&variable2=”+controllname + “&variable3=”+controllname………..);

Ex. 



Response.Redirect(“Page2.aspx?email=”+TextBox1.Text+”&mobile=”+TextBox2.Text);



Page1.aspx
Email – tb
Page2.aspx
College tb2
RB(Page3.aspx?email=” Request.QueryString[“email”] + “&college=”+tb2)
Page3.aspx

QueryString implementation



Access QueryString

22.3 Application State

    - Application state is use to http protocol
    - Application state generally use to display current user in web application

How to Create Application State

Syntax :
        Application[“Variable”] = value/control

Ex.
        Application[“count”] = TextBox1.Text


How to Access Application Data

Syntax :
        Control = Application[“variable”].ToString();

Ex.
        Label1.Text = Application[“count”].ToString();


22.4 View State
    - View state is a state management system
    - View state store data on single page

How to Create View state
Syntax :
        Viewstate[“variable”]= control;
Ex.
        Viewstae[“email”] = TextBox1.Text


How to access viewstate
Syntax :
        Controll = viewstate[“variable”].ToString();
Ex.
        TextBox.text = ViewState["email"].ToString();



Create page – page1.aspx
Name – tb
Email – tb
Pwd – tb
Date – tb
Button – next
Logic
If user can input current date in a textbox then open (login.aspx) with all data transfer
Login.aspxEnter email – tb
Pwd – tb
Button – login
Match email and password using view state method
If match then display valid user otherwise display invalid user


22.5 Cookies

    - Cookies is use to store pieces of information (small data)
    - cookies is use to expire if condition does not match
    - if cookies expire then all data is automatically removes in cookies variable

How to Create Cookies
Syntax :
    Response.Cookies[“variable”].value = Controll
Ex.
    Response.Cookies[“email”].value = TextBox1.text;

How to Expire Cookies
    - in expiring concept using DateAndTime Library
 
Syntax :
    Response.Cookies[“variable”].Expires = DateTime.Now.AddMinutes(value);
Ex.
    Response.Cookies[“email”].expires = Datetime.Now.AddMinutes(1);


How to retriewe cookies

Syntax :
    Controll = Request.Cookies[“variable”].value;

Ex.
    Lbl1.text = request.Cookies[“email”].value;


Task 1
Create a form (home.aspx)
Enter name – tb
Enter Email – tb
Enter Password – tb
Button – login (open login.aspx)
Login.aspx
Enter email id – tb
Enter Password – tb
Button – login
Logic 1 – match email id and password (using cookies variable)
Logic 2 – if user cannot input valid data (time duration) then open home.aspx page



23. File Uploading

File – collection of information in proper formate

23.1 Types of file

    1. User file
    2. System file

23.2 File property
    Save,Create,Open,Delete

23.3 File Upload Controll

C:/mydocument/image/a.jpg - map path
Travelling the path is known as map path
~/upload/data.jpg
Image control property – image url property


fupload.aspx



fupload.aspx.cs




Assignment 2
Create a form - imagedata.aspx
Center of the screen – upload Student pic
File Upload Controll
Upload Button
Dropdown list
Image control
Button – show next page (preview.aspx)
Concept
1. All pictures name display (dropdown list)
2. If user can select image in adropdown list then display image preview (image controll)
3. If user can press command button then open preview.aspx page display selected image(fullscreen) session and Querysrtring



Assignment 3
Implementation of (Online exam) upload student pic basic detail and display scorecard with student pic
Using query string



Continue Task
1. Controll id
2. Try catch exception handling
3. Css / Bootstrap
4. JavaScript
5. Comments




24. Master Page - imp
    - Master page common to all webpages
    - Extension of master page (.Master)
    - Master page cannot execute
    - Master page is to be executed anyone aspx page


Section of masterpage
    1. Header
    2. Menu(file,about,contact,login)
    3. Footer
    4. Contentplaceholder section(design all aspx page)

Rules :
    - In master page contentplaceholder always blank
    - Remove Default content place holder in source page


How to Create Master Page ?
Select root > project > add new item > Web Form Master Page > Add


How to connect aspx page to master
Select root > project > add new item > select web form with master page


Student.Master

information.aspx

Contact.aspx




25. Validation

- Accept correct data in web application called validation

Types of Validation

25.1 Client side Validation
    - client side Validations use to a scripting language(JavaScript)
    - client side validation is use to javaScript
    - provide Id attribute to all control
    - accept all id inside the script using getElementById() method

Syntax
    getElementById(“<%= controlID.ClientID%>”);

Ex.
    <asp : TextBox ID=”txtuname” runat=”server” >


What is Prefix?
It representing the control identity
Types of Prefix

1. Predefined (use in dot net framework - <asp :>)
2. User Defined (Ajax -<employee :>


Function cascading
How to access javascrmethod in c# code
access javascrmethod in c# code using attribute methodology

Assignment 3
Online Exam Module
screen 1 – Sever Side validation
Screen 2 – javaScript validation
Screen 3 – Combine Both Validation




<script language ="JavaScript" type="text/javascript">

function validationcheck() 
{
        var summery = "";
        summery += isValidEmail(); //function cascading
        summery += isValidPwd();

    if (summery != "")
    {
            alert(summery);
            return false;
    }
     else 
    {
            return true;
    }
}

function isValidEmail() 
{
    var id;
    var temp = document.getElementById("<%=txtemail.ClientID%>");
    id = temp.value;

    if (id == "")
   {
            return ("please enter email");
    }
    else 
    {
            return "";
    }
}

function isValidPwd() {
        var id;
        var temp = document.getElementById("<%=txtpwd.ClientID%>");
        id = temp.value;
        if (id == "") {
                return ("please enter password");
        }
        else {
            return "";
        }

}

</script>


//giving validation
btncreateexam.Attributes.Add("onclick", "javascript:return validationcheck()");


25.2 Server Side Validation
    - using validation control

How to Create Server Side Validation

RequiredFieldValidator
RangeValidator
RegularExpressionValidator
CompareValidator
ValidationSummery



1. RequiredFieldValidator

Property –
    - ErrorMessage
    - ControllToValid
    - EnableClientScript (Optional Property if not support in your dotnet version then using optional property)



How to enable validation script in dotnet framework
    - all types of management in web application using config file(configuration)
    - Using validation script inside <configuaration> tag
    - EnableClientScript == true

<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>


2. RangeValidator
Property
    - ErrorMessage
    - ControlToValid
    - MinValue
    - MaxValue


3. RegularExpressionValidator(check regularity of data)
Ex. mobno, email, pincode etc
Property.
    - errormessage
    - ControlToValid
    - ValidationExpression (all Expression on Net)

1.email expression
2.password expression
3.pincode Expression
Mobile No. Expression : \d{10}


4. CompareValidator
Property :
    - Errormessege
    - ControlToValid - first
    - ControlToCompare - second



Assign 1
Create a registration Form
Name :
Email :
Enter Company Mail : tb (accept only @mastersoft.com) ex. ramesh@mastersoft.com
Mobile :
Password :
PinCode :
Button – Submit
Logic
1. Use validation
-email(accept generic )
1. mobile no validation aceept only +91 country code
3.pincode validation
Logic 2
If all validation is success then open messege.aspx page where display all registered information


Types of mail
1.Generic mail
2.web mail – ex. webmail.tcs.com


5. Validation Summery
    - Display all error message at the end of program



var letters=  /^[A-Za-z]+$/;
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
var paswd= /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{7,15}$/;
var cardno = /^(?:3(?:0[0-5]|[68][0-9])[0-9]{11})$/;
var dateformat = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;

Assg 2
Implementation of Validation summery in task 1



25.2 Advantage and Disadvantage

    - client side validation is light waited
    - server side control (high weighted concept)



26. Class and Object (DotNet Framework) – most imp
    - All class store inside App_code directory
    - All database store inside App_data directory

How to Create Class

Step – go to solution explorer > select root > project menu > add new item > select class > name of the class

How to Access Class in aspx page

How to Pass Data Between aspx page to class page

Task 2
Create a Page
Registration.aspx
Name : tb
Email – tb
Mobile – tb
Subject – tb
M1 – tb
.
.
M5 – tb
Total – tb
Grade – tb
Button – submit
Logic 1 create a class college
Create a method display
Aceept following parameter (subject,m1….m5,)
Calculate total
Display grade
Total > 250 – A grade
Otherwise – B grade
Total and grade display in textbox control


Microsoft SQL Server Management Studio (17,19,18) exclude 2022



19-12-2023
27. Database Connectivity – most imp

- Database is generally use to backend concept
- Connect sql server to dotnet framework using sql server library


How to connect database in aspx page?

Step 1 :
include database library
    
    Sql Server – sqlclient
    XML – xml
    Excel – oledb
    MS access – oledb


Step 2 : Create database Object (built in object)

1. Connection object- SQLConnection – read database location(path/connectionstring)
2. Command Object – SQLCommand – read all query (insert,update,delete,select etc)
3. Data Reader Object – SQLDataReader – only use select query
Note : all object is to be create before the page load event


Step 3 : Break the page Refreshment

Note : this condition is use inside the page lode event

    If(! IsPostBack)
    {

    }





28. Database Management Using C#

There are following method is use to managing database entity

28.1 Parameterized Method
2. Class and Object Method
3. Store Procedure Method
4. 3 tier Architecture Method


Syntax :
    Variable = value;
    Object(variable)

Examples

String k = “insert”;
Com = new SqlCommand(k);

String d = “Delete”
Com = new SqlCommand(d);

String u = “update”
Com = new SqlCommand(u);

String s = “select”
Com = new SqlCommand(s);

String p = “Path”
Con = new SqlConnection(p);



Coding Steps

Step 1 : Open Your Database
    
    string path = connection string
    con = new SqlConnection(path);
    con.Open();
  

Step 2 : Applye Command/Query
    
    string k = query;
    com = new SqlCommand(k,con);
    
 
Step 3 : Execute Command
    
     //use for for insert, update and delete query
    com.ExecuteNonQuery();  
   

    //use for Select query
     dr = com.ExecuteReader();

     if(dr.Read())
     {
        //display column data value to specific controll
        TextBox2.Text = dr["Name"].ToString();
        TextBox3.Text = dr["City"].ToString();
     }
    


28.1 Parameterized Method

 - In this method is use to parameter variable
 - All parameter variable is represent @ operator
 - Prameter variable depend on database column

Ex .
Roll - @roll1
Name - @name1
City - @city1

- How to pass data in a parameter variable

Syntax:
    CommndObject.Parameters.AddWithValues(“variablename”,controlname);

Ex.
    Com.Parameters.AddWithValue(“roll1”,TextBox1.Text);
    Com.Parameters.AddWithValue(“name1”,TextBox2.text);
    Com.Parameters.AddWithValue(“city1”,TextBox3.Text);



Command Object Parameter
SQLCommand(variable,ConnectionObject);


Database Location Finder : @



Update Query
Update Student set name = @name1 where Roll = @roll1;
Com = new SqlCommand(k,con);
Com.Parameter,AddWithValue(“roll1”,txtroll.Text);
Com.Parameter,AddWithValue(“name1”,txtname.Text);



How to Use Select Query in C#
1. Select Query is use to DataReader object
2. DataReader returning two specific condition (True/False)
3. dataReader is close after end of program




Task 1
Create a webform Registration.aspx
Roll – tb find btn
Name – tb
Email – tb
Mobile
City – ddl(fix city ngp pune mum)
Subject – ddl (cse,it, civil)
Mark1 – tb
.
Mark 5 – tb
Total – tb
Grade – tb
Submit update Delete
Logic
1. create a table Student with all column
2. Generate total if all marks is greater than 40
3. Insert record in a table in following condition
    1.all mark greater than 40
    2.display grade total>250 Agrade total>150<250 b grade otherwise fail
    3.total and grade insert in a database if all subject mark greater than 40
4. Duplicate Roll no. cannot insert in a database exclude primary key
5. update all record on the bases of roll no. (do not change sub mark total grade)
6. Delete Record as per Specific roll no.
7. use validation (email,mobile)
8.. accept only string datavalue (name text baox) find by google
9.After submit complete information in a database open message.aspx page where display Congratulation message and print all specific information using database (logic on pageload)in notisPostback event
10. form designing using css also message.aspx



29. Data Bound Control – imp

- Databound control directly communicate to database column.
- There are some types of databound control
    1. Dropdown List
    2. RadioButton List
    3. Checkbox List

- Databound Control is use to some specific properties
    1. DataSource = datareader object
    2. DataTextField = Name of the column 
    3. DataBind





30. Handling Scaler Function in Database Connectivity – imp

- Scaler function cannot use datareader object

Create form
Id - tb
Name - tb ,
Code - tb btn – generate code
City - tb
Btn - submit
Ex

ID                Name               Code               City
1                  xyx          STU-2023-00-1      Nagpur
2                  abc          STU-2023-00-2      Pune
3                  efg          STU-2023-00-3      Mumbai





31. Connection String Management

- Connection string management using config file (web.config)
- Inside wen.config file using <AppSetting> tag
- Inside AppSetting tag using <add> tag
- Attributes of <add> tag
    1. Key – user defined
    2. Value – connection string

How to get Connection String (web.config to aspx page)

Step 1 : include configuration library
    Using System.Configuration;

Step 2 : using ConfigurationManager.appSetting[“keyname”];
    Ex = string path = ConfigurationManager.appSetting[“mydb”];




32. Data Controll (Machine Test Topic) – imp

- Using data visualization
- Datasource and databind property

32.1 Grid view
32.2 Repeater
32.3 DataList
32.4 DetailView
32.5 FormView
32.6 ListView



32.1 Grid View

- display row and column formate

How to Connect Database column to gridview control

Method 1 : using BoundFieldMethod
Click mastertag > > edit column >> select BoundField


Property of BoundField
1. HeaderText – user defind
2. DataField – column name


How to Remove Extra column in a grid view
Click edit column option > auto-generate field uncheck


How to Set formate in a grid view
Select grid view > auto formate




Imp
Grid View implementation


A. Gridview footer concept
B. Insert control inside gridview
C. Gridview event handling
D. Auto generate column in a grid view
E. How to bind image in a grid view control 
F. Crud Operation (create , read, update, delete)
G. Dynamic column binding
6. Gridview paging concept
8. Grid view export to pdf/excel




A. Grid View Footer

- connect footer inside the gridview using show footer property
    Show Footer = true
-all grid view column start with 0 index
 
    string k1 = "select count(Id) from StudentDemo";
    com = new SqlCommand(k1, con);
    GridView1.FooterRow.Cells[2].Text = "total : "+ com.ExecuteScalar().ToString();




B. How to insert control inside grid view – imp

Step 1 : create Template field (Inserting all control inside grid view)
            Property of template field – header text

Step 2 : Create <itemtemplate> tag inside template field

Step 3 : create all control inside <itemTemplate>




C. Grid View Event handling

- if the control outside of the grid view then using foreach loop
- if the control inside the grid view then using namingcontainer logic

Method 1 : Outside Control

Step 1 : using foreach loop
Syntax:
    Foreach(gridViewRow obj in GridView1.rows)
    {

    }

Step 2 : inside the foreach loop find out gridview control

Syntax:
    Controll objname = (Controll) RowObject.FindControl(“controllid”);
Ex.  
    TextBox txtmark = (TextBox) r1.FindControl("txtm");
    Response.Write(txtmark.Text);


How to read bound field inside foreach loop





23-12-2023

Review Topics
1. Database connectivity(inbuild environment)
2. Database Connectivity(SQL Server)
3. Connection String Using WebConfig File- imp
4. Connect Database to aspx page using c# code(library,object,!ispostback)
5. Performs Basic queries in C#(insert update delete and select)
6. How to use scaler function in C#(id generation)
7. DataBound Control(Dropdown,Radio etc)
8. Property of databound control
9. How to break repeated data value using code(without primary key)
10. How to use session / Query string in database concept
11. Data Control (Grid View)
12. Basic Binding(Bound field)
13. Template field (header text)
14. How to insert control inside templateField(<itemTemplate>)
15. Grid view event handling (outside control, foreach)
16. Grid view footer(show footer)
17. How to display data inside footer(FooterRow.Cells[0])
18. Grid view Cell counting (0)





D. Grid View Auto Generate Column

Roll           Name         City

1                  xyz          Nagpur

2                  abc          Pune

5                  efg          Delhi


-  Auto generate column is use to Template field




Grid View Errors

1. Field or property does not found - //columnname mistack
- Check column name/ datafield property check/ blank space in column name




E. How to bind image in a grid view control

- bind any types of images inside grid view control using imagefield property
- there are following properties used in imagefield
    1. header text
    2. dataimageurlfield - name of the column
    3. dataImageUrlFormateString – location(folder name) ex. ~/upload/{0}

How to control Image Attribute (height width)

Using <controlStyle> tag inside the <imageField> tag



F. Grid View Event Handling (Inside the control – naming container)crud operation - imp

Step 1 : using templatecolumn
Step 2 : create event control inside the templateColumn(button, linkbutton, etc)
Step 3 : create event using OnClick statement


How to create naming container

Syntax:
    GridViewRow obj = ((Control)Sender).NamingContainer AS GridViewRow;

Ex.
    GridViewRow r1 = ((Button)Sender).NamingContainer AS GridViewRow;
    GridViewRow r2 = ((LinkButton)Sender).NamingContainer AS GridViewRow;


protected void btnViewData_Click(object sender, EventArgs e)
{
    //GridViewRow obj = ((Control)Sender).NamingContainer AS GridViewRow;
    GridViewRow r1 = ((Button)sender).NamingContainer as GridViewRow;
    Response.Write("testing");
}



Display Cell value inside NamingContainer

protected void btnViewData_Click(object sender, EventArgs e)
{
    //GridViewRow obj = ((Control)Sender).NamingContainer AS GridViewRow;
      GridViewRow r1 = ((Button)sender).NamingContainer as GridViewRow;
    /display Cell value
    Response.Write(r1.Cells[2].Text);
}


How to find control inside naming Container

protected void btnViewData_Click(object sender, EventArgs e)
{
    //GridViewRow obj = ((Control)Sender).NamingContainer AS GridViewRow;
      GridViewRow r1 = ((Button)sender).NamingContainer as GridViewRow;
    //find Conroll
    TextBox txtM = (TextBox) r1.FindControl("txtMark");
    Response.Write(txtM.Text);
}




G. Dynamic Binding (Control) -imp

- Cells method not use in development With further changes in table

Update – update Student set Name = @name1 where Roll = @roll1;
Com = ………..
Com.Parameter.AddWithValue(“roll1”,r1.Cells[1].Text);

- Dynamic binding process is use to connect database column to specific control inside gridview
- Dynamic binding is use to Eval()
- Eval() function is used (Text property)

Syntax:
    Text = ‘<%# Eval(“ColumnName”) %>’;
Ex.
    Text = ‘<%# Eval(“Name”) %>’;




-  




H. How to use single template field in a grid view control



Note : Cannot use block of code inside !IsPostBack Condition
Solution : Function()


I. Grid View Paging Concept

Step 1 : In grid view paging we have to use allowpaging attribute
Datareader – read single record at a time

Bulk Reading Concept
- Using dataSet object
- Using SqlDataAdapter object (bulk reading)
- Dataset library – using system.Data;
- Command object cannot use (DataSet and dataAdapter)

How to Activate paging
- To activate the page in a grid view using OnPageIndexChanging Event



default.aspx

default.aspx.cs



32.2 Repeater Control

- Display data in a row formate


A. Repeater Event handling

1. Inside the repeater cannot use OnClick Event
2. Inside the repeater only use commandName event

<asp:Button ID="btnShow" runat="server" Text="Show" CommandName="display" />



B. How to activate commnd name
Activate command name inside the repeater using OnItemCommand Attribute


C. How to Find Control Inside the Repeater(Inside If Condition)
Syntax :
Control objName = (Control)e.Item.FindControl(“id”);
Ex.
Label lblname = (Label)e.Item.FindControl(“Label2”);


D. How to perform event handling outside the control
Using for loop
Control objname = Repeater1.Items[i].FindControl(“controlid”) as Control;





27-12-2023
32.3 Data List Control

- Data list control is use to display data in a form of column formate
- Datalist generally use to e commerce product layout

A. Attributes of Data List Control


1. RepeatColumns
2. RepeatDirection


B. Event Handling in data List Control


Data list and repeater use same type of event handling

Create Data List using Ecommerce CatLog CSS
Create a form
ID: tb
Product name - tb
Cost - tb
Upload product photo - tb
Selling Cost – tb
Submit – btn
Show – btn
Logic
1. Form designing (CSS)
2. Display all product in dataList Control(CSS Catlog)
3. Design data list Control in following formate
Photo
Product name
Cost of product
Text box – Enter Your Cost
Btn – buy Now (If user Click buy now btn then selected product display on next page(productview.aspx))
Logic
If user can input any cost inside the textbox then check following condition
Usercost !> not greater Cell Cost and not less than 500 Cost
Ex.
Id – 101
Product name – laptop
Cost – 5000
Photo – laptop.jpeg
Sell cost – 8000
Datalist lisplay
Photo (laptop.jpeg)
Product name (laptop)
Sell cost – 8000
Tb- 2000
Btn – buy now(product cannot be sell)
If tb – 7000




32.4 Form view Control

- Form view control is use to display data record in form format
- Form view is generally use admit card creation result creation
- Form view control view one record at a time

Property of Eval()
1.eval with control
2.eval without control

A. Form View Event Handling
- Form view Event Handling(Similar to Repeater , Data List concept)

- form view editor is work on row format - find any type of control inside form view using formviewRow object



Date:29-12-23
Imp-
32.5 List View Control -

1.GridView is used to high weighted server side control reduce this drawback we have to used ListView control
2.Their are following templateField used in ListView control-

1.LayOutTemplate- create record header
2.GroupTemplate- placeholder is just like container area.
3.ItemTemplate- connecting control with data record.

ListView attributes-
1.GroupPlaceholderId
2.ItemPlaceholderId
3.OnItemCommand


Task 1:
Implementation of ListView-
1.paging -(dataPager- Next - previous)
2.crud operation(update,del,insert,view)
3.css



32.6 Detail View control-

1.detailView control is used to display data in detail format.

Task 2:
Create templateField inside detailView perform event handling.


33. Store Procedure Connectivity Inside aspx page

CREATE PROCEDURE prodemo (@Roll1 as INT ,@Name1 as varchar(50),@City1 as varchar(50))
AS
BEGIN
INSERT into Student (Roll,Name,City) values(@Roll1,@Name1,@City1);
END;



Step 1 : include Library (System.Data)
Step 2 : In Store procedure is use to command type property

In store procedure concept sql command object is use to specific parameters

SqlCommand(“procedurename”,ConnectionObj);
SqlCommand(“prodemo”,con);

34. Data Tables

1.DataTable library is used to auto searching facility
2.DataTable is a built-in library stored in DataTable folder.

View Pdf


35. 3Tier Architecture

3 tier architecture is used to 3 specific layer-

a. presentation layer- only aspx page(project folder).
b. Data access layer- (only used database).
c. Business layer- create variable/member.

3 Tier Implementation : View Pdf
3 Tier CRUD Example : View Pdf

How to create 3 tier architecture?


Step : 1 Create class library(Dot Net Framework)
    
    1.BuisnessObject – only create variable
    2.BuisnessLogic- connect aspx page
    3.DataAccess- only database handling


Working flow-(3 tier architecture)-
(design page(.aspx)) -----à BuisnessLogic layer -----à DataAccess layer ---à BuisnessObject

Step:

Right click on solution explorer-> Add -> new project


Step: 2 Create class file inside each library-
1. BuisnessObject – UserBo
2. DataAccess – UserDA
3. BuisnessLogic – UserBL

right click on library -> add -> class



Step: 3 Set the references-
a. DataAccess – add reference BuisnessObject
b. BuisnessLogic – DataAccess,BuisnessObject
c. aspx page – (project folder) – BuisnessLogic,BuisnessObject

right click on library -> add -> project reference

step: 4 Do all classes as public.




36. Access html textbox inside button event
<Input> tag – client side control
<asp:> tag – server side control






37. Display empty grid view

There are two attribute is to be set inside grid view
1. ShowHeaderWhenEmpty = “true”;
2. EmptyDataText = “Message”;
Ex. EmptyDataText= “No Record Found”;





38. Email programming

Step 1 : include mail library(using System.Net.Mail)

There a two types of mail
1. Generic mail
2. Domain Mail

Mail Property

To, from, subject, body

Mail Protocol
- SMTP(Simple mail transport protocol)


Mail format = HTML


Mail Objects


1. MailMessage Object
Set mail property-to,from,subject,body

2. SMTPClient Object
Set the mail credential (id/password)

SMTPClient object
- Only used verified mail

Set the mail Server (host)

Types of Password

1.System Password (device passwords)
2.Network Password(gmail,yahoo etc)
3.Documentry Password (file,pdf)

Mail Security

SSL – Server Security Licensee

How to create encrypted passwords
  

protected void btnSend_Click(object sender, EventArgs e)    
{                                                                                                  
    MailMessage msg = new MailMessage();                            
    //set the mail property                                                            
    msg.To.Add(txtemail.Text);                                                    
    msg.From=new MailAddress("rajkamalhatwar@gmail.com");
    msg.Subject = "This is testing mail";                                            
    msg.Body = "Welcome !";                                                          
                                                                                                          
    //set htm formate = true                                            
    msg.IsBodyHtml = true;                                          
                                                                                        
    //using smtp client object                                            
    SmtpClient stp = new SmtpClient();                            
    stp.Port = 587;                                                                
    stp.Host = "smtp.gmail.com";                                            
    stp.Credentials = new System.Net.NetworkCredential("rajkamalhatwar@gmail.com", "mxnr wcuu cumd icig");                                                            
    stp.EnableSsl = true;                                                
    //send mail                                                                
    stp.Send(msg);                                                        
}                                                                                    


Sending Grid View On Mail




39. How to display calendar
- Using culture info implementing date and time
- All date and time concept used in globalization
- Working of date and time parameter using date and time object
    
protected void Button1_Click(object sender, EventArgs e)
{
        // Label1.Text = txtdate.Text;
        //using datetime object
        DateTime thedate =
DateTime.ParseExact(txtdate.Text,"yyyy-MM-dd",System.Globalization.CultureInfo.InvariantCulture);
        string finaldate = thedate.ToString("dd-MM-yyyy");
        Label1.Text = finaldate;
}

TextMode="Date"




40. Ajax configuration

How to Connect Ajax in DotNet Framework
1. Store ajax.dll inside bin directore
2. Add References ()
3. Include Register Assembly inside the source page

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

4. create css (optional)
5. using scriptmanger tag inside form tag(activate ajax toolkit)
6. ModelPopupExtender control

Attribute
1. ID
2. runat
3. popupcontrolid
4.targetcontrolid(showbutton)
5.cancel control id(closebutton)
6.backgroundcssclass= classname





40.1 Ajax calendar
40.2 Ajax Popup

41. Grid View RowDatabound event






42. Random number Concept



43. How to Create Dynamic Directory(Runtime)
1. Include IO Library

 protected void btnCreate_Click(object sender, EventArgs e)
 {
     //create directory
     Directory.CreateDirectory(Request.MapPath(txtname.Text)+"/");
     Response.Write("Directory Created");
 }



Comments

Popular posts from this blog

C# Programming

SQL(Structure Query Language)