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
203 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net checkbox 7 46
Crystal reports vb.net 2 39
VB.Net Report Printing Issue 3 31
Modal Popup Extender control 1 18
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 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

18 Experts available now in Live!

Get 1:1 Help Now