Crete Connection with connection string.  SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[“PropertyGuruConnectionString”].ToString());     //Make an Open Connection to the SQL Server database //Here ‘PropertyGuruConnectionString’ is the name of the string used for connection with database //Our aim is to add Checkbox values in Database //Lets Add a three checkboxes with different values and a button to submit those values in database table. //We need to create the database table for storing values as well. On Button Click Here Three Checkboxes have Respective Ids – chkApartment, chkVilla, chkRest protected void btnPropType_Click(object sender, EventArgs e)     {         if (chkApartment.Checked == true)         {            lblRandom3.Text = “Apartment”;        Read More →

It is sometimes needed to generate random integers in C# programming. Random integers can be used  for human verification in Math Captcha . Random integers can be used for sms verification etc. Let’s see how to do it. Our Aspx Code <asp:Content ID=”Content2″ ContentPlaceHolderID=”MainContent” Runat=”Server”>     <asp:Label ID=”lblRandom” runat=”server” Text=”Label”></asp:Label>     <asp:Label ID=”lblRandom2″ runat=”server” Text=”Label”></asp:Label>     <asp:Label ID=”lblSum” runat=”server” Text=”Label”></asp:Label> </asp:Content> lblRandom for generation of 1st Random Character lblRandom2 for generation of 2nd Random Character lblSum to generate Sum of 2 random numbers Now C# Code – protected void Page_Load(object sender, EventArgs e)     {         Random rnd = new Random();         int month =Read More →

You can use following code to print any statement in php. Start your Php Code using – <?php //end it using – ?> Any php function, statement, declaration etc goes between the starting and ending tags. Lets Print – “Hello World” in your browser using php. <?php echo “Hello World”; // echo is used to print any statement or value in php. ?> Copy and paste the code in your .php file to run.Read More →

A Folder Named App_Code is created by Visual Studio in our Application by Default. We have to create a Public Class in that folder. And then write our function which we want to replicate in multiple pages. Then :- In the respective pages simply create the object of that public class, all the objects will be able to access all the public functions of that class. In the class (in App_code) public class themainclass {    public void tobereplicatedfuntion()    {       // Do Something you want to replicate } ____________________ In Respective Pages (New object ) themainclass objthemainclass = new themainclass(); objthemainclass.tobereplicatedfuntion(); _________________________________________  Read More →

What are destructors in C # In C # Class is instantiated when Constructors are used but when an Object of a Class is deleted Class Destructors are automatically invoked. There can be only one destructor for a class. A Destructor is not called / cannot be called, it is invoked automatically. A Destructor cannot be modified using modifiers A Destructor cannot have parameters A Destructor Shares same name with the Class but a “ ~ ”  TILDE is used with it Let’s see an example: Classname | ~Classname Example Program in C# class Person { public Person() { Console.WriteLine(“This is a Constructor”); } ~Person()Read More →

Insert Values into Database in using C# Here is How Our Aspx file will look in Design View – Please Note : Respected “IDs” of Form Fields. Use Following Namespaces in your C# code : using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Text; using System.Data.SqlClient; using System.Configuration; Code your button click like this : On Button Click An Insert Statement will be executed Note : In our case Table Columns are country, city and area and their values will be fetched from DropDownlist1 , txtCity and TextCountry respectively. protected void btnCity_Click(object sender, EventArgs e) { tryRead More →