473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Back color property in button

44
Hello Friends
I have created the project with 2 forms. In the first form, I have 2 buttons. The first button has the backcolor as "fusia" by default. If I click the button means then backcolor of the button should change into red color. Thats why I have given the coding as
Expand|Select|Wrap|Line Numbers
  1.  
  2. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         If Button1.BackColor = Drawing.Color.Fuchsia Then
  4.             Button1.BackColor = Drawing.Color.Red
  5.         End If
  6.     End Sub
  7.  
The another button is the "Go" button which redirects to the next page.

In my next form I have the textbox with one button asking for the credit card number . If the valid credit card number is entered in the textbox & the button is clicked, then the back color of the button1 in the previous form should get changed into blue color.

I have created the sql table named "seat1". In that I have the following fields as sno,b1,b2. The table has the data as
sno b1 b2
--------------------------
1 fu fu
---------------------------

fu-------> fusia as back color
b1------->button1
b2------->button2

Just like that in the b1 field (with sno as 1) in the DB should change into "bl" which means "Blue as BackColor". For that, I have created the session variable in the previous form & used that variable. The coding is as follows

PREVIOUS FORM:
Expand|Select|Wrap|Line Numbers
  1.  Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. Dim obj5 As Object
  3.         obj5 = Button1.BackColor
  4.         Session.Add("b1", obj5)
  5.     End Sub
  6.  
NEXT FORM:
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim obj5 As Object
  3.         obj5 = CObj(Session("b1"))
  4.  End Sub
  5.  
Now the thing is If I click the "Button1" in the 2nd form then in the DB it should get updated as in the following manner

sno b1 b2
--------------------------
1 bl fu
---------------------------
and at the same time button1 in the previous form should have the back color as blue by default. For this I have given the coding as
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
  3. Dim obj5 As Object
  4.         obj5 = CObj(Session("b1"))
  5. Dim con As SqlConnection
  6.         Dim cmd As SqlCommand
  7.         Dim str As String
  8.         Dim rd As SqlDataReader
  9.         str = "user id=sa;password=;data source=AURO-RA4;initial catalog=suganya;server=AURO-RA4"
  10.         con = New SqlConnection(str)
  11.         Try
  12.             con.Open()
  13.         Catch
  14.         End Try
  15.         cmd = New SqlCommand
  16.         cmd.Connection = con
  17.         cmd.CommandText = "select count(credit) from credit where credit='" & Trim(TextBox3.Text.ToString()) & "'"
  18.         Dim cnt As Int16
  19.         cnt = cmd.ExecuteScalar()
  20.         If cnt <= 0 Then
  21.             Response.Write("Un authorise user")
  22.         Else
  23. Dim str1, str2 As String
  24.             str1 = "user id=sa;password=;data source=AURO-RA4;initial catalog=suganya;server=AURO-RA4"
  25.             con = New SqlConnection(str1)
  26.             Try
  27.                 con.Open()
  28.             Catch
  29.             End Try
  30.             str2 = "update seat1 set b1='bl' where sno='1'"
  31.             cmd = New SqlCommand(str2, con)
  32.             cmd.ExecuteNonQuery()
  33.             con.Close()
  34.             obj5 = Drawing.Color.Blue
  35.         End If
  36.     End Sub`
  37.  
If I run the above, it is getting inserted in the DB but the back color of the button1 in the previous form is not getting changed into "blue" color & still it retains red color.
Apr 2 '08 #1
0 1119

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Javier | last post by:
Hello, I'm very new in this forum and as I have the following problem, the website is in http://new.vanara.com ----------------------------------------------------------------------------...
5
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial...
25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
4
by: belgie | last post by:
Is there a way to prevent the user from using the browser Back Button to go back to a previous page in an ASP.NET application? Thanks! Bill
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
2
by: Ersin Gençtürk | last post by:
I show errors as popup boxes via alert() but I write this scripts in header of html page.So if there is an error on the server side , in the next postback a popup shows the error via alert , this...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I the page knows there was a cross post back. but i can not find the control. (asp.net 3.5) calling page has a master calling control: <asp:Button ID="btnSendAlert" runat="server" Text="Go"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.