Tuesday 9 August 2016

Write a program to display reverse of string in ASP.NET

This post will help you to demonstrate a program to display the reverse of a string in ASP.NET. You can copy this code after you open a blank project in IDE of ASP.NET(Visual Studio). Then try to run that copied code, at that time you will get an expecting output.

In this program we are trying to find reverse of a string that we entered in text-box. For this, we used one text-box and one label to print output, and a button to perform this function. There you can see these text-box and a button also in the output. But the label will be hidden, it will only visible after you try to find the output.Then enter any string that you want to check its reverse, after that click on the button. Then you will get the output. The output will be reverse of the string that you have entered in the text-box field. We hope this code will help you to be a developer or a programmer. Before copying, try to understand the method that we used to find the output. Click on the read more button to get this code.

Monday 8 August 2016

Write a program to bind data to dropdown using aspx.cs page in ASP.NET

This post will help you to demonstrate a program to bind data to drop-down using aspx.cs page  in ASP.NET. You can copy this code after you open a blank project in IDE of ASP.NET (Visual Studio). Then try to run that copied code, at that time you will get an expecting output. In this program we are trying to bind data to drop-down using aspx.cs page. For this, we used one dropdownlist and one label to print output, and a button to perform this function. There you can see these drop-down and a button also in the output. The label will show as "The result will shown here", it will change after you try to change the value of drop-down in the output.Select any option from that drop-down, after that click on the button. Then you will get the output on the label. The options are added using aspx.cs page. We hope this code will help you to be a developer or a programmer. Before copying, try to understand the method that we used to find the output. Click on the read more button to get this code.

Sunday 7 August 2016

write a program to display table controls in asp.net

tablecontrol.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="tablecontrol.aspx.cs" Inherits="our_program.tablecontrol" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    
    <form id="form1" runat="server">
<center>
    <div>
    <asp:Table ID="Table1" runat="server">
    <asp:TableHeaderRow><asp:TableCell>username</asp:TableCell>
    <asp:TableCell >address</asp:TableCell>
    <asp:TableCell>gender</asp:TableCell>
    <asp:TableCell>place</asp:TableCell>
    </asp:TableHeaderRow>
    <asp:TableRow><asp:TableCell>shafi</asp:TableCell>
    <asp:TableCell>shafi</asp:TableCell>
    <asp:TableCell>shafi</asp:TableCell>
    <asp:TableCell>shafi</asp:TableCell>

    </asp:TableRow>
<asp:TableRow>
<<asp:TableCell>pa</asp:TableCell>

</asp:TableRow>
    </asp:Table>
    
   </div>
    </form>
</body>
</html>

tablecontrol.aspx.cs

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

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

        }
    }
}

Saturday 6 August 2016

write a program to check entered number is between 1 and 100 using range validator in asp.net

range_validator.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="range_validator.aspx.cs" Inherits="our_program.range_validator" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Range validator</title>
    <center><h1>Range validator</h1></center>
    <script runat="server">

      void btnclick(Object sender, EventArgs e)
      {

         if (Page.IsValid)
         {
             lbl.Text = "entered value is between 1 and 100 Page is valid.";
         }
         else
         {
            lbl.Text="entered value is between 1 and 100 Page is not valid!!";
         }

      }

   </script>
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div>
   
    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <br />
    <br />
   
    <asp:RangeValidator ID="RangeValidator1" runat="server"
        ErrorMessage="RangeValidator" MaximumValue="100" MinimumValue="1" ControlToValidate="txt1" Type="Integer" EnableClientScript="false" Text="please enter value between 1 and 100"></asp:RangeValidator>
    <asp:Label ID="lbl" runat="server" Text=""></asp:Label>
    <br />
    <br />
    <asp:Button  ID="btn" runat="server" Text="submit" OnClick="btnclick"/>
    </div>
    </center>
    </form>
</body>
</html>


range_validator.aspx.cs

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

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

        }
    }
}

write a program to display prime numbers in a range in asp.net

primerange.aspx.cs

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="primerange.aspx.cs" Inherits="our_program.primerange" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <center><h1>prime in a range</h1></center>
</head>
<body>
    <form id="form1" runat="server">
     <center>
    <div>
     
    <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="btn" runat="server" Text="Button" onclick="btn_Click"  />
    <br />
    <br />
    <asp:Label ID="lbl" runat="server" Text="result are shown here"></asp:Label>
   

   
    </div>
    </center>
    </form>
</body>
</html>

primerange.aspx.cs

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

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

        }

        protected void btn_Click(object sender, EventArgs e)
        {
            int l = Convert.ToInt16(txt.Text);
            int u = Convert.ToInt16(txt1.Text);
            string output = "";
            int a = l + 1;
            for (int i = a; i < u; i++)
            {
                int f = 0;
                for (int j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                        f = 1;
                        break;
                    }
                }
                if (f == 0)
                {
                    output = output + "<br>" + i;
                }
            }
            lbl.Text = "prime numbers b/w " + l + " and " + u + " are " + output;

        }
    }
}

write a program to display odd numbers in a range in asp.net

oddrange.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="oddrange.aspx.cs" Inherits="our_program.oddrange" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>odd in a range</title>
    <center><h1>odd in a range</h1></center>
</head>
<body>

    <form id="form1" runat="server">
    <center>
    <div>
       
    <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="btn" runat="server" Text="Button" onclick="btn_Click"  />
<br />
    <br />
    <asp:Label ID="lbl" runat="server" Text="result are shown here"></asp:Label>
   

    </div>
    </center>
    </form>
</body>
</html>

oddrange.aspx.cs

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

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

        }

        protected void btn_Click(object sender, EventArgs e)
        {
            int l = Convert.ToInt16(txt.Text);
            int u = Convert.ToInt16(txt1.Text);
            string output = "";
            int a = l+1;
            for (int i = a; i < u; i++)
            {
                if (i % 2 == 1)
                {
                    output = output + "<br>" + i;
                }
            }
            lbl.Text = "Odd numbers b/w " + l + " and " + u + " are " + output;

        }
    }
}

write a program to display N prime numbers in asp.net

N_prime.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="N_prime.aspx.cs" Inherits="our_program.N_prime" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>N prime number</title>
    <center><h1>N prime numbers</h1></center>
</head>
<body>
    <form id="form1" runat="server">
     <center>
    <div>
     
        <asp:TextBox ID="txt" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="bt" runat="server" Text="Button" onclick="bt_Click"  />
        <br />
        <br />
        <asp:Label ID="lbl" runat="server" Text="result are shown here"></asp:Label>
   

    </div>
    </center>
    </form>
</body>
</html>

N_prime.aspx.cs

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

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

        }

        protected void bt_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt16(txt.Text);
            int prime = 0;
            int l = n * 2;
            string output = "";
            for (int i = 2; i < n * 4; i++)
            {
                int f = 0;
                for (int j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                        f = 1;
                        break;
                    }
                }
                if (f == 0)
                {
                    output = output + "<br>" + i;
                    prime++;
                }
                if (prime == n)
                {
                    break;
                }
            }
            lbl.Text = "prime numbers are " + output;
        

        }
    }
}