Tuesday, August 28, 2018

Common Language Runtime Framework


                    Common Language Runtime Framework:

  • As part of the Microsoft  .NET Framework, the Common Language Runtime (CLR) is the programming (Virtual Machine component) that manages the execution of programs written in any language that uses the .NET Framework, for example C#, VB.Net, F# and so on.
  • Programmers write code in any language, including VB.Net, C# and F# yhen they compile their programs into an intermediate form of code called Common Language Infrastructure (CLI) in a portable execution (PE) file that can be managed and used by the CLR and then the CLR converts it into machine code  will be executed by the processor.
  • The information about the environment, programming language, its version and what class libraries will be used for this code are stored in the form of metadata with the compiler that tells the CLR how to handle this code.
  • The CLR allows an instance of a class written in one language to call a method of the class written in another language.

Functions of the CLR:
  • Convert code into CLI.
  • Exception handling
  • Type safety
  • Memory management (using the Garbage Collector)
  • Security
  • Improved performance
  • Language independency
  • Platform independency
  • Architecture independency 
Components of the CLR
  • Class Loader (Each assembly has its own class loader to load types from that assembly)

    Used to load all classes at run time.
     
  • Microsoft Intermediate Language(MSIL- Microsoft Intermediate Language (MSIL) is a language used as the output of a number of compilers (C#, VB, .NET, and so forth)) to Native code

    The Just In Time (JTI) compiler will convert MSIL code into native code.
     
  • Code Manager

    It manages the code at run time.
     
  • Garbage Collector

    It manages the memory. Collect all unused objects and deallocate them to reduce memory.
     
  • Thread Support

    It supports multithreading of our application.
     
  • Exception Handler

    It handles exceptions at run time.

Coding Techniques & Coding Standards

                                                     Coding Techniques:
  • Inline Coding
  • Code Behind

1.Inline Coding:
        It contains both Designer Code & Business Logic in  .aspx page.
2. Code Behind:
         Designer Code in  .aspx page
         Business Logic in  .aspx.cs page
What is Designer Code?
                It is  required for designing the UI.
What is Business Logic?
                It is required for executing the logic behind the screen.

                                           Coding Standards of C# Asp.Net:
·         Pascal Casing: - First character of all words are Upper Case and other characters are lower case.(class names, method names)
Ex: BackColor
·         Camel Casing: - First character of all wordsexcept the first word are Upper Case and other characters are lower case.(variable names & method parameters)
Ex: backColor
·         Do not use single character variable names like i, n, s etc. Use names like index, temp
One exception in this case would be variables used for iterations in loops:
for ( int i = 0; i < count; i++ )
{
       ...
}
·         Do not use underscores (_) for local variable names.
·         Namespace names should follow the standard pattern
<company name>.<product name>.<top level module>.<bottom level module>
·         Use appropriate prefix for the UI elements so that you can identify them from the rest of the variables.
a.     Use a common prefix ( ui_ ) for all UI elements. This will help you group all of the UI elements together and easy to access all of them from the intellisense.
b.     Use appropriate prefix for each of the ui element. A brief list is given below. Since .NET has given several controls, you may have to arrive at a complete list of standard prefixes for each of the controls (including third party controls) you are using.
Control
Prefix
Label
lbl
TextBox
txt
DataGrid
dtg
Button
btn
ImageButton
imb
Hyperlink
hlk
DropDownList
ddl
ListBox
lst
DataList
dtl
Repeater
rep
Checkbox
chk
CheckBoxList
cbl
RadioButton
rdo
RadioButtonList
rbl
Image
img
Panel
pnl
PlaceHolder
phd
Table
tbl
Validators
val
·         File name should match with class name.
For example, for the class HelloWorld, the file name should be helloworld.cs (or, helloworld.vb)
·         Use Pascal Case for file names.

Monday, August 27, 2018

Quick Mail Coding in Asp.Net

                                 Quick Mail Coding in Asp.Net

  • ) Use this name space 

        using System.Net;

        using System.Net.Mail; 


  • Add this code in your button click:

        MailMessage msg = new MailMessage();

        msg.From = new MailAddress("sasigujai@gmail.com");
        msg.To.Add("examples@gmail.com");
        msg.CC.Add("examplej@gmail.com");
        msg.Subject = "tst";
        msg.Body = "<p>  Name"+TxtboxID.Text+" </p>
       <p>Last  Name "+ TxtboxID.Text+"</p>
       <p> Message "+ TxtboxID.Text+"</p> ";
        msg.IsBodyHtml = true;

//*If you want to upload any fine
        if (FileUpload1.HasFile)
        {
            msg.Attachments.Add(new Attachment
(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
        }

        SmtpClient smt = new SmtpClient();
        smt.Host = "smtp.gmail.com";
        System.Net.NetworkCredential ntwd = new NetworkCredential();
        ntwd.UserName = "sasigujai@gmail.com"; //Your Email ID  
        ntwd.Password = "****** "; // Your Password  
        smt.UseDefaultCredentials = true;
        smt.Credentials = ntwd;
        smt.Port = 587;// Have to Command this line
        smt.EnableSsl = true;
        smt.Send(msg);
        Response.Write("<script> alert('Email Sent Successfully')</script>");
      

Solving SMTP Error in Mail Settings

                How to solve SMTP  error in mail settings


Change account access for less secure apps
  • Option 1: Install a more secure app that uses stronger security measures. All Google products, like Gmail, use the latest security measures.
  • Option 2: Change your settings to allow less secure apps into your account. We don't recommend this option because it can make it easier for someone to break into your account. If you want to allow access anyway, follow these steps:

  1. Go to the Less secure apps section of your Go
  2. Turn on Allow less secure apps. If you don't see this setting, your administrator might have turned off less secure app account access.

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

                              

Common Language Runtime Framework

                    Common Language Runtime Framework: As part of the Microsoft  .NET Framework, the Common Language Runtime (CLR...