Click here to Skip to main content
15,888,208 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have taken 10 button control named as 1,2,3,..0
what would be the coding for entering digits in two textboxes using same buttons in same form
Posted
Comments
Krunal Rohit 16-Mar-14 11:50am    
Elaborate.

-KR
Peter Leow 16-Mar-14 12:00pm    
Let me guess - When the button named as 2 is clicked, the number 2 appears in textbox and so on...??
But why 2 textboxes???
Not clear.
anita roy 16-Mar-14 12:16pm    
yes u meant right...
i have taken two texboxes because in textbox1 i have to enter card no(label1)..if the card no is valid in database then i should be able to enter pin no(label2) in textbox2 using these buttons....so kindly tell me the coding of buutons only...

If I understand correctly, you mean that at client side (in browser) in web page you have two texboxes. First user types in textbox1 to enter card no(label1).....if the card no is valid in database (I hope you are checking using AJAX call) then user should be able to enter pin no(label2) in textbox2 using same buttons.

It can be done at client side JavaScript as described here:
http://stackoverflow.com/questions/9920662/insert-text-to-selected-textbox-use-javascript[^]

If above link does not help, please explain specific scenario and tell something about your code.
 
Share this answer
 
v2
VB
Imports System.Data
Imports System.Data.SqlClient

Partial Class details
    Inherits System.Web.UI.Page
    Dim con As New SqlConnection
    Dim cmd As New SqlCommand
    Dim str As String
    Dim str1 As String
    Dim dr As SqlDataReader
    Dim i As Integer


    Protected Sub Button14_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button14.Click
        '-validation
        If TextBox1.Text = "" Then
            Label5.Text = "Enter Proper Value"
        End If
        If TextBox1.Text.ToString.Length <> 5 Then
            Label6.Text = "Must Be 5 Character"

        End If
        

        '-------------

        con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=E:\THE ATM SYSTEM\App_Data\Database.mdf;Integrated Security=True;User Instance=True")

        Session("card_no") = TextBox1.Text.ToString
        Session("pin_no") = TextBox1.Text.ToString
        con.Open()
        str = ("select * from registration where card_no='" + TextBox1.Text + "'")
        cmd = New SqlCommand(str, con)
        dr = cmd.ExecuteReader
        If dr.Read Then
            Label4.Visible = True
            TextBox2.Visible = True
        End If
        str1 = ("select * from registration where pin_no='" + TextBox2.Text + "'")
        cmd = New SqlCommand(str1, con)

        While dr.Read()
            i = i + 1
        End While
        If i > 0 Then
            Response.Redirect("choose.aspx")
        End If

        con.Close()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        TextBox1.Text = TextBox1.Text + Button1.Text
        Label5.Text = ""
        Label6.Text = ""



    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        TextBox1.Text = TextBox1.Text + Button2.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = TextBox1.Text + Button3.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox1.Text = TextBox1.Text + Button4.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Text = TextBox1.Text + Button5.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox1.Text = TextBox1.Text + Button6.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox1.Text = TextBox1.Text + Button7.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox1.Text = TextBox1.Text + Button8.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox1.Text = TextBox1.Text + Button9.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    Protected Sub Button10_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button10.Click
        TextBox1.Text = TextBox1.Text + Button10.Text
        Label5.Text = ""
        Label6.Text = ""
    End Sub

    
End Class


This much coding i have done..but not getting the logic for entering in textbox2..
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900