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
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 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