Asp.Net Web Forms Projects

All - C:\Users\vasan\source\repos\WebApplication7_March2023

Installation 
https://visualstudio.microsoft.com/downloads/
https://www.microsoft.com/en-in/sql-server/sql-server-downloads

https://www.youtube.com/watch?v=Ivvwh-7H2ek
https://www.youtube.com/watch?v=C_KeaoJ6-Gc

https://www.programiz.com/csharp-programming/online-compiler/
-------------------------------
Install IIS
Turn on windows service
crete a web application
publlish from visual studio
copy the bin folder from published location
paste to required location
add website in iis , change port , don't add host name 
then browse
Edit permission - security - system - find now - below 2 option add





For Sql use sql connection auth sa - helloram
-iis- change application pool setting like below 






-----------------------------------------------------------------------------

http://www.developerin.net/a/39-Intro-to-.Net-FrameWork/23-Components-of-.Net-Framework

Components of .Net Framework


There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of .Net Framework.

Components of .Net Framework


Net Framework is a platform that provides tools and technologies to develop Windows, Web and Enterprise applications. It mainly contains two components,

1.   Common Language Runtime (CLR)

2.    .Net Framework Class Library.

1. Common Language Runtime (CLR)

.Net Framework
 provides runtime environment called Common Language Runtime (CLR).It provides an environment to run all the .Net Programs. The code which runs under the CLR is called as Managed Code. Programmers need not to worry on managing the memory if the programs are running under the CLR as it provides memory management and thread management.

Programmatically, when our program needs memory, CLR allocates the memory for scope and de-allocates the memory if the scope is completed.

Language Compilers (e.g. C#, VB.Net, J#) will convert the Code/Program to Microsoft Intermediate Language (MSIL) intern this will be converted to Native Code by CLR. See the below Fig. 

MSILCode.jpg

There are currently over 15 language compilers being built by Microsoft and other companies also producing the code that will execute under CLR.

2.    .Net Framework Class Library (FCL)

This is also called as Base Class Library and it is common for all types of applications i.e. the way you access the Library Classes and Methods in VB.NET will be the same in C#, and it is common for all other languages in .NET.

The following are different types of applications that can make use of .net class library. 

1.                   Windows Application.

2.                   Console Application

3.                   Web Application.

4.                   XML Web Services.

5.                   Windows Services.

In short, developers just need to import the BCL in their language code and use its predefined methods and properties to implement common and complex functions like reading and writing to file, graphic rendering, database interaction, and XML document manipulation.

Below are the few more concepts that we need to know and understand as part of this .Net framework. 

3.   Common Type System (CTS)

It describes set of data types that can be used in different .Net languages in common. (i.e), CTS ensures that objects written in different .Net languages can interact with each other.

For Communicating between programs written in any .NET complaint language, the types have to be compatible on the basic level.

The common type system supports two general categories of types: 

Value types:


Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations.

Reference types:


Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates. 

4. Common Language Specification (CLS)

It is a sub set of CTS and it specifies a set of rules that needs to be adhered or satisfied by all language compilers targeting CLR. It helps in cross language inheritance and cross language debugging.

Common language specification Rules:


It describes the minimal and complete set of features to produce code that can be hosted by CLR. It ensures that products of compilers will work properly in .NET environment. 

Sample Rules: 

1.       Representation of text strings 

2.       Internal representation of enumerations 

3.       Definition of static members and this is a subset of the CTS which all .NET languages are expected to support.

4.   Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.

Below mentioned the .Net Architecture stack for easy understanding.

https://www.c-sharpcorner.com/article/bitwise-operations-in-C-Sharp/





---------------------------------------------------







int4 byte-2,147,483,648 to -2,147,483,647
long8 byte?9,223,372,036,854,775,808 to 9,223,372,036,854,775,807


Data TypeSizeDescription
int4 bytesStores whole numbers from -2,147,483,648 to 2,147,483,647
long8 bytesStores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
float4 bytesStores fractional numbers. Sufficient for storing 6 to 7 decimal digits
double8 bytesStores fractional numbers. Sufficient for storing 15 decimal digits
bool1 bitStores true or false values
char2 bytesStores a single character/letter, surrounded by single quotes
string2 bytes per characterStores a sequence of characters, surrounded by double quotes

Console.WriteLine();

Console.ReadLine();

Debug


Abstract & interface

https://vasanthrv.blogspot.com/2022/08/aspnet-web-interface-and-abstract.html


Constructer & Destructer


All Projects

C:\Users\vasan\source\repos\WebApplication6


RedirectsAnd PageLifeCycle & File Upload

C:\Users\vasan\source\repos\RedirectsAndPageLifeCycle


Continue - C:\Users\vasan\OneDrive\Desktop\Online Class\AspNetProjects\Asp_Sp_Sql

1. Demo Sql & session , redirect etc - C:\Users\vasan\OneDrive\Desktop\Online Class\Demo


2.Web service -

https://www.c-sharpcorner.com/UploadFile/1d42da/web-service-basics/

C:\Users\vasan\OneDrive\Desktop\Online Class\Projects\Web service\WebApplication3

<system.webServer>
    <defaultDocument>
       <files>
          <add value="insertion.aspx" />
       </files>
    </defaultDocument>
    <directoryBrowse enabled="false" />
</system.webServer>


3.IFrame & Application object - C:\Users\vasan\OneDrive\Desktop\Online Class\rajesh\deleteproj\deleteproj


c# https://www.tutorialspoint.com/asp.net/asp.net_custom_controls.htm


4.page life cycle - https://www.c-sharpcorner.com/UploadFile/8911c4/page-life-cycle-with-examples-in-Asp-Net/

C:\Users\vasan\OneDrive\Desktop\Online Class\AspNetProjects\PageLifecycle\PageLifecycle

5.net_validators - https://www.tutorialspoint.com/asp.net/asp.net_validators.htm

C:\Users\vasan\OneDrive\Desktop\Online Class\AspNetProjects\aspValidation\AspNetValidation\AspNetValidation

C:\Users\vasan\OneDrive\Desktop\Online Class\AspNetProjects\DemoControls_Validation

Validations - https://drive.google.com/file/d/1bsqpCjQc1R-001XKIKIb0HqPPoCrVWRy/view


6.State , cookie , session, redirect C:\Users\vasan\source\repos\Insert_view_Asp_net\Insert_view_Asp_net


7.File Upload - https://www.c-sharpcorner.com/article/Asp-Net-2-0-fileupload-control/

C:\Users\vasan\OneDrive\Desktop\Online Class\Projects\@asp\ASPNetControls


8.MasterPage - https://www.c-sharpcorner.com/article/how-to-create-master-page-in-asp-net/

C:\Users\vasan\OneDrive\Desktop\Online Class\AspMasterPage\masterpage

9.Insert & View From Sp and cookies  -  C:\Users\vasan\source\repos\Insert_view_Asp_net

ExecuteReader ExecuteNonQuery ExecuteScalar 

https://www.aspdotnet-suresh.com/2012/09/executescalar-example-in-aspnet-using-c.html

https://www.aspdotnet-suresh.com/2012/09/executereader-executenonquery.html

10.validation and state management -

https://www.aspdotnet-suresh.com/2011/05/what-is-use-of-globalasax-file-in.html

i)C:\Users\vasan\OneDrive\Desktop\Online Class\AspNetProjects\StateManagement\StateManagement

https://github.com/vasanth32/AspNetStateManagement

 ii)C:\Users\vasan\OneDrive\Desktop\Online Class\Projects\validation and state management

--------------------------------------------------------

  1. protected void Button1_Click(object sender, EventArgs e)    
  2.     {    
  3.         Response.Redirect("SecondPage.aspx");  
  4.     }    
  5.     protected void Button2_Click(object sender, EventArgs e)    
  6.     {    
  7.         Server.Transfer("SecondPage.aspx");    
  8.     }    
  9.     protected void Button3_Click(object sender, EventArgs e)    
  10.     {    
  11.         Response.Redirect("http://www.mcnsolutions.net");    
  12.     }    
  13.     protected void Button4_Click(object sender, EventArgs e)    
  14.     {    
  15.         Server.Transfer("http://www.mcnsolutions.net");  
  16.     }    
  17.  protected void Button5_Click(object sender, EventArgs e)    
  18.     {    
  19.         Server.Execute("http://www.mcnsolutions.net");  
  20.     }   
  21. Server.Execute

----------------------------------------------------------


11.Encrypt & Decrypt

public class HelloWorld

{

    public static void Main(string[] args)

    {

        string encryptedString = HelloWorld.EnryptString("sourceString");    

   string encryptedString1 = HelloWorld.DecryptString(encryptedString);  

        Console.WriteLine (encryptedString1);

    }

 public static string EnryptString(string strEncrypted)   

{  

    byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(strEncrypted);  

    string encrypted = Convert.ToBase64String(b);  

    return encrypted;  

public static string DecryptString(string encrString)  

{  

    byte[] b;  

    string decrypted;  

    b = Convert.FromBase64String(encrString);  

        decrypted = System.Text.ASCIIEncoding.ASCII.GetString(b);      

    return decrypted;  

}  

}

-------------------------------

ExecuteScalar (select single value)

Execute Scalar will return first row first column value i.e. it will return single value and ignore other values on execution of SQL Query or Stored procedure using command object. It’s very fast to retrieve single values from database.

ExecuteNonQuery(update / insert / delete)

ExecuteNonQuery method will return number of rows effected with INSERT, DELETE or UPDATE operations. 

ExecuteReader (select all rows)

Execute Reader will be used to return the set of rows, on execution of SQL Query or Stored procedure using command object. This one is forward only retrieval of records and it is used to read the table values from first to last.

--------------------------------




Delegates

// Online C# Editor for free

// Write, Edit and Run your C# code using C# Online Compiler


using System;

delegate void Procedure();

public class DelegateDemo 

{

    public static void channel1()

    {

        Console.WriteLine("channel 1");

    }

    public static void channel2()

    {

        Console.WriteLine("channel 2");

    }

    public static void channel3()

    {

        Console.WriteLine("channel 3");

    }

    public static void Main(string[] args)

    {

      Procedure someProcs = null;

        someProcs += new Procedure(channel1);

        someProcs += new Procedure(channel2);  // Example with omitted class name

        someProcs();

    }

}

https://www.javatpoint.com/events-in-c-sharp

--------------------------------




----------------------------

Page Life Cycle

* When a page is requested, it is loaded into the server memory, processed, and sent to the browser. Then it is unloaded from the memory

At each of these steps, methods and events are available, which could be overridden according to the need of the application. In other words, you can write your own code to override the default code.

Understanding the page cycle helps in writing codes for making some specific thing happen at any stage of the page life cycle




ASP.NET Page Life Cycle Events

At each stage of the page life cycle, the page raises some events, which could be coded. An event handler is basically a function or subroutine, bound to the event, using declarative attributes such as Onclick or handle.

Following are the page life cycle events:

  • PreInit - PreInit is the first event in page life cycle. It checks the IsPostBack property and determines whether the page is a postback. It sets the themes and master pages, creates dynamic controls, and gets and sets profile property values. This event can be handled by overloading the OnPreInit method or creating a Page_PreInit handler.

  • Init

    1. This event fires after each control has been initialized.
    2. Each control's UniqueID is set and any skin settings have been applied.
    3. Use this event to read or initialize control properties.
    4. The "Init" event is fired first for the bottom-most control in the hierarchy, and then fired up the hierarchy until it is fired for the page itself.
  protected void Page_PreInit(object sender, EventArgs e)
    {
        
        //Note : If page is post back or first time call and you have not set any values to ViewState["value"], then
        //Convert.ToString(ViewState["value"]) is always empty.
        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "PreInit";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        /*
        1. This event fires after each control has been initialized.
        2. Each control's UniqueID is set and any skin settings have been applied.
    */

        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "Init";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected void Page_InitComplete(object sender, EventArgs e)
    {
        /*
         1. Till now the viewstate values are not yet loaded, hence you can use this event to make changes to view state that you want to make sure are persisted after the next postback.
         2. Raised by the  Page object. 
         3. Use this event for processing tasks that require all initialization be complete.     
       */

        //Note : If page is post back or first time call and you have not set any values to ViewState["value"] in privious events, then
        //Convert.ToString(ViewState["value"]) is always empty.
        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "InitComplete";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected override void OnPreLoad(EventArgs e)
    {

        /*
          1. Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance.   
          2. Before the Page instance raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.
        */

           ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "PreLoad";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        
        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "Load";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        
        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "btnSubmit_Click";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected void Page_LoadComplete(object sender, EventArgs e)
    {
        /*
        1. Raised at the end of the event-handling stage.
        2. Use this event for tasks that require that all other controls on the page be loaded.
      */

        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "LoadComplete";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected override void OnPreRender(EventArgs e)
    {
        /*
         1. Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls.
         2. The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page.
       */

        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "PreRender";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected override void OnSaveStateComplete(EventArgs e)
    { /*
          1. Raised after view state and control state have been saved for the page and for all controls. 
          2. Before this event occurs, ViewState has been saved for the page and for all controls.
          3. Any changes to the page or controls at this point will be ignored.
          1. Use this event perform tasks that require view state to be saved, but that do not make any changes to controls.
        */

        //But "SaveStateComplete" values will not be available during post back. i.e. View state.
        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "SaveStateComplete";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }

    protected void Page_UnLoad(object sender, EventArgs e)
    {
        //1.This event is used for cleanup code.
          //2. At this point, all processing has occurred and it is safe to dispose of any remaining objects, including the Page object.        ViewState["value"] = Convert.ToString(ViewState["value"]) + "<br/>" + "UnLoad";
        lblName.Text = Convert.ToString(ViewState["value"]);
    }





------------------------------------------











 ~HelloWorld()
    {
        GC.SuppressFinalize(this);
    }







Comments

Popular Posts