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
201 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
Comment Utility
you need to do a checkbox1_oncheckchanged event on your code behind page
0
 

Author Comment

by:cbdrako99
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Expert Comment

by:maralans
Comment Utility
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
Comment Utility
sorry "value in the textbox as the event will never fire."
0
 
LVL 5

Expert Comment

by:maralans
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

7 Experts available now in Live!

Get 1:1 Help Now