.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

background color change using button

Posted By:SanthoshNathan       Posted Date: December 14, 2010    Points: 15    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

background color change using button
 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

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>Untitled Pagetitle>

head>

<body id="bodytag" runat="server">

    <form id="form1" runat="server">

    <div>

        <asp:Button ID="Button1" runat="server" Height="26px" Style="z-index: 100; left: 100px;

            position: absolute; top: 65px" Text="Red" Width="116px" />

        <asp:Button ID="Button2" runat="server" Height="26px" Style="z-index: 100; left: 439px;

            position: absolute; top: 61px" Text="blue" Width="116px" />

        <asp:Button ID="Button3" runat="server" Height="26px" Style="z-index: 100; left: 262px;

            position: absolute; top: 65px" Text="green" Width="116px" /><asp:Button ID="Button5" runat="server" Height="26px" Style="z-index: 100; left: 778px;

            position: absolute; top: 60px" Text="brown" Width="116px" />

        <asp:Button ID="Button4" runat="server" Height="26px" Style="z-index: 100; left: 622px;

            position: absolute; top: 63px" Text="pink" Width="116px" />

   

    div>

    form>

body>

html>

 

Code:

*****************

Partial Class _Default

    Inherits System.Web.UI.Page

     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        bodytag.Attributes("bgcolor") = "red"

    End Sub

     Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

        bodytag.Attributes("bgcolor") = "green"

    End Sub

     Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        bodytag.Attributes("bgcolor") = "blue"

    End Sub

     Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click

        bodytag.Attributes("bgcolor") = "pink"

    End Sub

     Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click

        bodytag.Attributes("bgcolor") = "brown"

    End Sub

End Class



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend