Web Applications

Dot Net area in web application

1.Design area - .aspx

2.Source area - It will automatically created in HTML format.

3.Code area - Create in C# with extension  aspx.cs (.CS only for logic code)

How to create first web application.

Process:-
File > New > Website > C# > ASP.NET Website > Browse > Directory > ok

Windows :-
1. Solution explorer window  :- Display all file and folder.
2.Server explorer window :- Only work on database.
3.Tool box:- All types of tools (eg. radio button,checkbox,etc)
4.Property Window :- All property display in property window (color,height,width,etc).

How to configure web application (first time)

Step 1:- Remove all file in solution explorer

Step 2:- Delete account folder in solution explorer

How to create webpage

In dot net webpage is called webform.
Process:- 
step 1:- Go to the solution explorer
step 2:- Select root directory (here root directory means top file on solution explorer window)
step 3:- Click website menu
step 4:- Click on add new item
step 5:- Select language C#
step 6:- Select webform. 

IMP

HTML->1st page->index 
php->1st page->index/home
java->1st pg->index.jsp
.net->1st pg->default.aspx

  • common property of all the control used in dotnet is text.
  • double click on any control only in case of coading


Navigation

There are two methods of Navigation

  1. Using Control(i.e.tools)
  2.  Using code

Using Control 

1.linkbuttoncontrol
2.hyperlinkcontrol
3.imagebutton control

Property of link button control
1.Text Property 
2. Postbackurl-connect webpage

Hyperlink control is used to control any other website(URL)
Property :- 1.text
                  2.Navigation URL property (set the web URL)

Imagebutton is used to navigate one page to another page using image.
Property :-
1.Imageurl
2. Postbackurl

Navigation using code

There are two method used to navigate one page to another page using code
 
1.on page navigation (display page name:-response.redirect( ))
2.off page navigation (hidden page name:- server.transfer( ))

Note:- Text box input concept
 1.number input:-int.Parse( )
 2.decimal input:- double.Parse( )

Note:-"" is representing the blank data.

How to change textbox background color?

important point:
  • dot net support above 256 colors.
  • all color stored inside the drawing library.
  • in programming lang. ,cursor is called as focus.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int a, b, c;
        if (TextBox1.Text == "" || TextBox2.Text == "")
        {
            Response.Write("please input all data");

        }
        else
        {
            a = int.Parse(TextBox1.Text);
            b = int.Parse(TextBox2.Text);
            c = a + b;
            TextBox3.Text = c.ToString();
            //change the background color
            TextBox3.BackColor = System.Drawing.Color.Aqua;
            //how to blank textbox
            TextBox1.Text = "";
            TextBox2.Text = "";
            //how to set cursor in a textbox
            TextBox1.Focus();

            
        }
    }
}

*****Date and time concept******

date time is a special type of class.it is used to handling date and time features.

**STATE MANAGEMENT**

It is a process used to navigation with data
1. Session
2.Query string
3. view State
4. Application State
5.Cookies

Session

1.session is a state management
2. default time limit 60 seconds
3. session is to be create inside the event 
4.Session data cannot view URL

How to create session
syntax-
session["variable"]=value/control;
eg.
session["email"]=textbox1.text
 
How to access session
1.ALL session is be accessed Page load event
syntax-
control=(string)session["variable"];
eg.
label1.text=(string)session["email"];

******Query string***********

1.it is a state management
2.query string data is to be display on URL
3.query string cannot use secure data

****HOW TO CREATE QUERY STRING*********

syntax:- Response.redirect("pagename.aspx?variable="+control);

***HOW TO ACCESS QUERY STRING*****

syntax:- control=Request.querystring["variable"];

querystring is used inside the pageload.


******MULTIPLE  variable in querystring*****

use multiple variable in querystring using & operator
syntaxt:Response.Redirect("pagename.aspx?variable="+control + "&variable="+ control+ "&variable="+control--------- ) 


******view state******


important points
1.view state is a clint side state management technique
2.view state store data on single page   

*****HOW TO CREATE VIEW STATE*****

syntax: viewstate["variable"]=value;


*****HOW TO ACCESS VIEWSTATE*****

syntax:- variable/control=viewstate["variable"].Tostring();

******File Upload Control****

  • file upload control is used to uploading any types of file in a website.
  • ~ is called as route directory finder
  • for file upload control make a folder in project directory.(use small letters to give the  folder name. )
  • folder is work on save as property. 
  • to add items in dropdown list,we have to use add().
1.dropdown is used to select event only.
2.dropdown coding is to be activated if autopostback property is true.
3.with the help of delete function delete all file inside the directory.

EXAMPLE: PROGRAM NAME: fupload.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;


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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        FileUpload1.SaveAs(Server.MapPath("~")+ "//upload//"+ FileUpload1.FileName);
        Label1.Text = FileUpload1.FileName;
        Image1.ImageUrl = "~/upload/" + FileUpload1.FileName;
        DropDownList1.Items.Add(Label1.Text);

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Image1.ImageUrl = "~/upload/" + DropDownList1.Text;
            
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        FileUpload1.SaveAs(Server.MapPath("~") + "//upload//" + FileUpload1.FileName);
        Label1.Text = FileUpload1.FileName;
        HyperLink1.NavigateUrl = "~/upload/" + FileUpload1.FileName;
        
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        //delete image
        string filename = DropDownList1.Text;
        string path = Server.MapPath("~/upload/");
        //access the file information suing FileInfoclass object
        FileInfo file = new FileInfo(path + filename);
        if (file.Exists)
        {
            file.Delete();
            Response.Write("file deleted");

        } 
        else
        {
            Response.Write("file not found");
        }
        
    }
}   

********  DotNet Validation  **********

  • Accepting correct information only is called validation.
  • In dot net use some type of validation control 

1.required field validator control
2.range validator control
3.compare validator control
4.regular expression control
 
Properties os controls
 1.required field validator:-
    a.error message property
    b.control to validate property
    
 2.range validator control
   It generally used for setting range between two values.
   a.error message property
   b.control to validate property
   c.Min value
   d.max value 

 3.regular expression control
   In this type of control is basically used to check the regular data value like mobile    no,email address,etc.
   a.error message
   b.control to validate
   c.validation expression :-\d{10}

4.compare validator control
In this control used to compare two value
 a.error message
 b.control to compare
 c.control to validate 
 

Important unit:- master page creation

common to all webpage
importance of master page
1.master page cannot be executed. 
2.there are four section in master page
   a.header
   b.footer
   c.menu
   d.contained place folder
3.master page is to be connected aspx page.


how to create master page.

1.select root - add new item - master page(file extention:- .master)-ok
2.go to the source code and remove containedplaceholder tag.(at first time)
3.for table cell selection press shift key with up/down/right/left arrow.
4.contained place holder is used to display all pages connected to master page.
5.contained place holder always blank inside the master page.

how to connect aspx page to master page.

select master page option (visual studio 2010)
webform with master page(2019 or above version)
Radio button list control.
 1.It used to indexing(0------).
 2.radio button list select one item at a time.

******Template*******

Template is a pre defined structure.
types of template
1.html template
2.jquery template
3.boostrap template:-it is a light weight template.
example: registration form website template free,educational form website template free,etc.
1.https://colorlib.com/wp/free-bootstrap-registration-forms/
2.https://www.free-css.com/free-css-templates

******CONVERT TEMPLATE TO DOT NET******

step1.find the template
step2.download the template
step3.extraxt the templates in folder location
step4.open template folder.
step5.find out the index page.(index.html)  
step6.copy folder(placed index.html)   
step7.paste this folder to desktop.
step8.rename the folder
step9.open this folder in dot net enviornment
step10.Run the program. 


******CONVERT INDEX PAGE TO aspx Page********

step 1.create aspx page(first page name is always default)
step2.open index page.
NOTE:not used design section in html template.(always use source section)
step3.go to the source section(index.html)and compress the page(<html>)
step4:-copy the code.
step5:open aspx page and go to the source section and remove all code(<html>)
step6:paste all code in aspx page.

****HOW TO CHANGE TEMPLATE*****

there are two method 
1.text change
2.graphics change

1.text change:only between the tag
eg.<b>welcome</b> 
menu: home,about,registration,fees,contact 

how to change image
right click on the image->save image as->and copy name-> 

how to create logo
how to write hindi font https://www.google.com/intl/hi/inputtools/try/

***********HOW TO CHANGE CONTROL IN WEB TEMPLATE******

Change HTML control to dot net
step 1: find the HTMLcontrol in a template and create dot net control.
step 2: copy class attribute in html control (only if class available).
step 3: paste dot net control(class attribute).
step 4:remove html control.

Error:Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with runat=server.
solution:- all dot net control create inside the <form>.
In html page use multiple form tag
In dot net page use only one <form>

IMP CONCEPT
***HOW TO MANAGE <FORM>***
step 1:find the <form>.
step 2:delete <form>.There are two methods used in deleting the <form>.
1.if class attribute not available in <form> then remove the <form>. 
2.if <form> is use class attribute then replace <form> in a <div> and remove all attribute excluding class attribute. 

****HOW TO INCLUDE DOT NET <FORM>*****
step 1: dot net <form> always use after the <body>.
syntax:<form id="form1" runat="server">
        </form>









   


Comments

Popular posts from this blog

C# console applications

DATATABLES

MVC(MODEL-VIEW-CONTROLLER)