Tuesday, July 24, 2018

how to calculate AREA OF A CIRCLE in asp.net | sradha webcreations



AREA OF A CIRCLE


            ENTER RADIUS OF A CIRCLE


            THE AREA OF CIRCLE IS




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

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

    }
    protected void ButtonCALCULATE_Click(object sender, EventArgs e)
    {
        float fRadius;
        float fArea;

        fRadius = Convert.ToInt32(TXTRADIUS.Text);
        fArea = (3*(fRadius*fRadius));
        TXTAREA.Text = Convert.ToString(fArea);

    }
    protected void ButtonSAVE_Click(object sender, EventArgs e)
    {
  string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
string insertSql = "INSERT INTO circle(radious,area) VALUES(@radious,@area)";

        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
  SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
  myCommand.Parameters.AddWithValue("@radious", TXTRADIUS.Text);
  myCommand.Parameters.AddWithValue("@area", TXTAREA.Text);

            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }

        // "Reset" the Subject and Body TextBoxes
        TXTRADIUS.Text = string.Empty;
        TXTAREA.Text = string.Empty;
        
    }
}

how to calculate PERIMETER OF RECTANGULAR in asp.net | sradha webcreations

PERIMETER OF RECTANGULAR
              ENTER WIDTH

             ENTER HEIGHT

  PERIMETER OF RECTANGULAR


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

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

    }
  
 protected void BTNCALCULATE_Click(object sender, EventArgs e)
    {
        float fWidth;
        float fHeight;
        float fPerimeter;
        fWidth = Convert.ToInt32(TextBoxWIDTH.Text);
        fHeight = Convert.ToInt32(TextBoxHEIGHT.Text);
        fPerimeter=2*(fWidth+fHeight);
        TextBoxRECTANGULAR.Text = Convert.ToString(fPerimeter);
       
    }
    protected void BTNSAVE_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertSql = "INSERT INTO perimeter(width,height,perimeter) VALUES(@width,@height,@perimeter)";

using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
    SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
    myCommand.Parameters.AddWithValue("@width", TextBoxWIDTH.Text);
    myCommand.Parameters.AddWithValue("@height", TextBoxHEIGHT.Text);
            myCommand.Parameters.AddWithValue("@perimeter",TextBoxRECTANGULAR.Text);

            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }

        // "Reset" the Subject and Body TextBoxes
        TextBoxWIDTH.Text = string.Empty;
        TextBoxHEIGHT.Text= string.Empty;
        TextBoxRECTANGULAR.Text = string.Empty;
    }
}



how to CONVERSION OF FAHRENHEIT TO CENTIGRADE in Asp.net | sradha webcreations



          ENTER FARENHEIT

          CENTIGRADE



  using System;
//using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

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

    }
    protected void btncalculate_Click(object sender, EventArgs e)
    {
        float fFarenheit;
        float fcentigrade;
        fFarenheit = Convert.ToInt32(txtfarenheit.Text);
        fcentigrade=(fFarenheit-32)*5/9;
        TXTCENTIGRADE.Text = Convert.ToString(fcentigrade);

    }
  
 protected void btnsave_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
        string insertSql = "INSERT INTO conversion(farenheit,centigrade) VALUES(@farenheit,@centigrade)";

        using (SqlConnection myConnection = new SqlConnection(connectionString))
        {
            myConnection.Open();
     SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
   myCommand.Parameters.AddWithValue("@farenheit", txtfarenheit.Text);
 myCommand.Parameters.AddWithValue("@centigrade", TXTCENTIGRADE.Text);

            myCommand.ExecuteNonQuery();
            myConnection.Close();
        }

        // "Reset" the Subject and Body TextBoxes
        txtfarenheit.Text = string.Empty;
        TXTCENTIGRADE.Text = string.Empty;
    }
}
               



https://www.facebook.com/Sradhawebeducation/
                                             

Monday, July 23, 2018

benefits of Web.config file |WEB.CONFIG FILE in asp.net | sradha WebCreations

How to connect database by using web.config file 

What is Web.Config File?

Configuration file is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code. Generally a website contains a single Web.config file stored inside the application root directory. However there can be many configuration files that manage settings at various levels within an application.

WEB.CONFIG FILE
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
       <appSettings/>
       <connectionStrings>
              <add name="dbconnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
       </connectionStrings>
       <system.web>
              <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
              <compilation debug="true" targetFramework="4.0">
              </compilation>
              <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
              <authentication mode="Windows"/>
              <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
              <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
       <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
</configuration>
1. in this file we can change the exesting connection  NAME to <add name=”dbconnection”

2.and  CHANGE THE  DATA BASENAME . HEAR DATA BASE NAME IS database.mdF. in this place we must enter the newly created data base name.
     <connectionStrings>
          <add name="dbconnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
     </connectionStrings>
     <system.web>

Usage of configuration file

ASP.NET Configuration system is used to describe the properties and behaviors of various aspects of ASP.NET applications. Configuration files help you to manage the many settings related to your website. Each file is an XML file (with the extension .config) that contains a set of configuration elements. Configuration information is stored in XML-based text files.