按钮控件在文本框中输入 [英] button controls to input in textboxes

查看:67
本文介绍了按钮控件在文本框中输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将10个按钮控件命名为1,2,3,.. 0

使用相同形式的相同按钮在两个文本框中输入数字的编码是什么

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

推荐答案

如果我理解正确,你的意思是在网页的客户端(浏览器中)你有两个texbox。第一个用户在textbox1中键入以输入卡号(label1).....如果卡号在数据库中无效(我希望您使用AJAX调用进行检查),那么用户应该能够在textbox2中输入pin no(label2)相同的按钮。



它可以在客户端JavaScript完成,如下所述:

http://stackoverflow.com/questions/9920662/insert-text-to-selected-textbox-use-javascript [ ^ ]



如果以上链接无效,请解释具体方案并说明您的代码。
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.


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





我已经完成了这么多编码..但没有得到输入textbox2的逻辑..



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


这篇关于按钮控件在文本框中输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆