23 Eylül 2012 Pazar

Simple Web Form Example

 

WebForm1.aspx


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server" >
    <div>
   
    <table border="2">
        <tr>
        <td>
        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large"
            ForeColor="#FF3300" Text="Ege Pizza"></asp:Label>
        </td>
        </tr>

       <tr>
       <td></td>
       <td>
        <asp:Label ID="Label2" runat="server" Text="Adet"></asp:Label>
       </td>
       <td></td>
       </tr>

       <tr>
       <td>
        <asp:CheckBox ID="CheckBox1" runat="server" Text="Combo Menu(7TL)" />
        </td>
        <td>
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>5</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td>
        <asp:Image ID="Image1" runat="server" Height="40px"
            ImageUrl="~/İmages/combo.jpg" Width="77px" />
        </td>
        </tr>

        <tr>
        <td>
        <asp:CheckBox ID="CheckBox2" runat="server" Text="Super Menu(8TL)" />
        </td>
        <td>
        <asp:DropDownList ID="DropDownList2" runat="server">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>5</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td>
        <asp:Image ID="Image2" runat="server" Height="40px"
            ImageUrl="~/İmages/super.jpg" Width="77px" />
        </td>
        </tr>
        </table>
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Label3" runat="server" Text="Odeme Sekli"></asp:Label>
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:RadioButton ID="RadioButton1" runat="server"
            Text="Nakit (%10 indirimli)" />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:RadioButton ID="RadioButton2" runat="server" Text="Kredi Kartı" />
        <br />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="Siparişi Ver" />
        <br />
        <br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox1" runat="server" Height="53px" TextMode="MultiLine"></asp:TextBox>
        <br />
        <br />
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   
    </div>
    </form>
</body>
</html>


WebForm1.aspx.cs


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

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

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            double total = 0.0;

            if (CheckBox1.Checked)
            {
                total += Convert.ToDouble(DropDownList1.SelectedIndex+1) * 7;
            }
            if (CheckBox2.Checked)
            {
                total += Convert.ToDouble(DropDownList1.SelectedIndex+1) * 8;
            }
            if (RadioButton1.Checked)
            {
                total = total * (0.9);
            }

            TextBox1.Text = total.ToString();
                       
        }
    }
}

Hiç yorum yok:

Yorum Gönder