Solved

How to conditionally copy the results of one textbox to another textbox depending on the status of a checkbox.

Posted on 2006-10-28
7
202 Views
Last Modified: 2010-04-23
Hello Experts,

I am creating a webform using VB.net to collect information and then email the results to a single recipient. The form asks for patient information and responsible party information.  Many times this is the same person.  If the checkbox is = true then fill in the responbile party fields with the text of the patient fields.  
Thanks in advance for your help.
0
Comment
Question by:cbdrako99
  • 3
  • 3
7 Comments
 
LVL 10

Expert Comment

by:gangwisch
ID: 17827112
you need to do a checkbox1_oncheckchanged event on your code behind page
0
 

Author Comment

by:cbdrako99
ID: 17827128
I already have that.  Here's my attempt at the code which doesn't work.

    Protected Sub chkRPSame_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkRPSame.CheckedChanged
        If chkRPSame.Checked = True Then
            txtRPFirstName.Text = txtPatFirstName
        End If
    End Sub

Any ideas?
0
 

Author Comment

by:cbdrako99
ID: 17827133
Sorry. The code is actually...

    Protected Sub chkRPSame_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkRPSame.CheckedChanged
        If chkRPSame.Checked = True Then
            txtRPFirstName.Text = txtPatFirstName.Text
        End If
    End Sub

But it does't do a thing.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:maralans
ID: 17827322
That code should work but only after you have typed in the value in the textbox and then checked the checkbox.  It won't work if the checkbox is checked prior to putting a value in the checkbox as the event will never fire.
0
 
LVL 5

Accepted Solution

by:
maralans earned 125 total points
ID: 17827325
sorry "value in the textbox as the event will never fire."
0
 
LVL 5

Expert Comment

by:maralans
ID: 17827336
I think you need something more like this:

Private Sub txtPatFirstName.Text_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPatFirstName.Text.TextChanged
        If chkRPSame.Checked = True Then
            txtRPFirstName.Text = txtPatFirstName.Text
        Else
            txtRPFirstName.Text = ""
        End If
    End Sub
0
 

Author Comment

by:cbdrako99
ID: 17827365
maralans,
Your'e right. I wasn't giving the control a chance to fire.  This was clearly a case of not seeing the forest for the trees.  Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now