Sunday, August 18, 2013

TableControl in Asp.Net

.aspx

<asp:Table ID="Table1" runat="server" BorderColor="DarkGreen" BorderWidth="1">  
                <asp:TableHeaderRow ForeColor="SeaGreen">  
                    <asp:TableHeaderCell>RollNumber</asp:TableHeaderCell>  
                    <asp:TableHeaderCell>Name</asp:TableHeaderCell>  
                    <asp:TableHeaderCell>Mark</asp:TableHeaderCell>  
                </asp:TableHeaderRow>  
               
                <asp:TableRow>  
                    <asp:TableCell>1</asp:TableCell>  
                    <asp:TableCell>ss</asp:TableCell>  
                    <asp:TableCell>33</asp:TableCell>
                </asp:TableRow>  
                
                </asp:Table>

Code

protected void btnAdd_Click(object sender, EventArgs e)
    {
        TableRow TRow = new TableRow();

        TableCell rollnocell = new TableCell();
        rollnocell.Text = txtroll.Text;
        TRow.Cells.Add(rollnocell);

        TableCell namecell = new TableCell();
        namecell.Text = txtname.Text;
        TRow.Cells.Add(namecell);

        TableCell markcell = new TableCell();
        markcell.Text = txtmark.Text;
        TRow.Cells.Add(markcell);

        Table1.Rows.Add(TRow);

     

       

    }

Image Maping in Asp.Net


.aspx

<asp:ImageMap ID="ImageMap1" runat="server"
                        ImageUrl="~/Class-22(ImageMap)/image/aspnet_imagemap.jpg"
                        onclick="ImageMap1_Click">
                       
                        <asp:RectangleHotSpot AlternateText="Facebook" Bottom="62"
                            HotSpotMode="Navigate" Left="14" NavigateUrl="http://www.facebook.com"
                            Right="152" Target="_blank" Top="11" />

                        <asp:RectangleHotSpot AlternateText="Twitter" Bottom="61"
                            HotSpotMode="Navigate" Left="156" NavigateUrl="http://www.twitter.com"
                            Right="306" Target="_blank" Top="11" />
           
                        <asp:CircleHotSpot AlternateText="WordPress" HotSpotMode="PostBack"
                            PostBackValue="WordPress" Radius="41" X="50" Y="118" />
           
                        <asp:CircleHotSpot AlternateText="BMW" HotSpotMode="PostBack"
                            PostBackValue="BMW" Radius="41" X="155" Y="121" />
     
                        <asp:CircleHotSpot AlternateText="Windows" HotSpotMode="PostBack"
                            PostBackValue="Windows" Radius="44" X="266" Y="122" />
           
                        <asp:PolygonHotSpot AlternateText="Star" HotSpotMode="PostBack"
                            PostBackValue="Star"
                            Coordinates="108,217, 141,210, 157,181, 173,210, 207,217, 184,242, 188,276, 158,261, 127,275, 131,243"
                            NavigateUrl="Star" />

                    </asp:ImageMap>


Code

   protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
    {
 Label1.Text = e.PostBackValue.ToString();

        /*if (e.PostBackValue == "BMW")
        {
            Response.Redirect("bmwdetails.aspx");
        }*/

    }

MultiView in Asp.net


Code:   


       MultiView1.ActiveViewIndex = 0;



MultiView1.ActiveViewIndex = 1;


.aspx 

<asp:MultiView ID="MultiView1" runat="server">
                    <asp:View ID="CourseDetails" runat="server" >
                        <table class="style1">
                            <tr>
                                <td class="style2">
                                    Course</td>
                                <td>
                                    <asp:TextBox ID="txtCourse" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    Fees</td>
                                <td>
                                    <asp:TextBox ID="txtFees" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    Duration</td>
                                <td>
                                    <asp:TextBox ID="txtDuration" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    &nbsp;</td>
                                <td>
                                    <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" />
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                    <asp:View ID="BookDetails" runat="server">
                        <table class="style1">
                            <tr>
                                <td class="style2">
                                    BookName</td>
                                <td>
                                    <asp:TextBox ID="txtBook" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    Auother</td>
                                <td>
                                    <asp:TextBox ID="txtAuthor" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    Price</td>
                                <td>
                                    <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    &nbsp;</td>
                                <td>
                                    <asp:Button ID="btnAdd" runat="server" Text="Add" />
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                    <asp:View ID="StudentsDetails" runat="server">
                        <table class="style1">
                            <tr>
                                <td class="style2">
                                    RegNo</td>
                                <td>
                                    <asp:TextBox ID="txtReg" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    Name</td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    Branch</td>
                                <td>
                                    <asp:DropDownList ID="ddlBranch" runat="server" Height="16px" Width="128px">
                                        <asp:ListItem>--select--</asp:ListItem>
                                        <asp:ListItem>CS</asp:ListItem>
                                        <asp:ListItem>EC</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="style2">
                                    &nbsp;</td>
                                <td>
                                    <asp:Button ID="btnUpdate" runat="server" Text="Update" />
                                </td>
                            </tr>
                        </table>
                    </asp:View>
                </asp:MultiView>

Chart in Asp.net

.aspx

  <asp:Chart ID="Chart1" runat="server" Palette="Bright">
                        <series>
                            <asp:Series Name="Series1">
                            </asp:Series>
                        </series>
                        <chartareas>
                            <asp:ChartArea Name="ChartArea1">
                            </asp:ChartArea>
                        </chartareas>
                    </asp:Chart>

Code (Example)

 protected void btnChart_Click(object sender, EventArgs e)
    {
        string sel = "select * from tbl_employee";
        DataTable dt = new DataTable();
        dt = obj.selectQuery(sel);
        Chart1.DataSource = dt;
        Chart1.Legends.Add("Salary").Title = "Salary";
        Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Name";
        Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Salary";
        Chart1.Series["Series1"].XValueMember = "empname";
        Chart1.Series["Series1"].YValueMembers = "empsalary";
      Chart1.Series["Series1"].ToolTip = "#VALY, #VALX";
        Chart1.DataBind();


    }