ASP.NET - TextBox control
- ຫນ້າຫນັງ WebForms ViewState
- ຫນ້າຫນັງ WebForms Button
TextBox control is used to create a text box where users can enter text.
TextBox control
TextBox control is used to create a text box where users can enter text.
TextBox control properties in our TextBox control reference manual。
ຄວາມຄິດຕາມທີ່ທ່ານອາດຈະໃຊ້ໃນ TextBox control:
<html> <body> <form runat="server"> TextBox ພື້ນຖານ: <asp:TextBox id="tb1" runat="server" /> <br /><br /> TextBox ທີ່ມີຄວາມຄິດຕາມລະບຸຄວາມຄິດຕາມ: <asp:TextBox id="tb2" TextMode="password" runat="server" /> <br /><br /> TextBox ທີ່ມີຄວາມຄິດຕາມ: <asp:TextBox id="tb4" Text="Hello World!" runat="server" /> <br /><br /> TextBox ທີ່ມີຄວາມຫຼາຍບັນຍາ: <asp:TextBox id="tb3" TextMode="multiline" runat="server" /> <br /><br /> TextBox ທີ່ມີຄວາມສູງ: <asp:TextBox id="tb6" rows="5" TextMode="multiline" runat="server" /> <br /><br /> TextBox ທີ່ມີຄວາມກວດ: <asp:TextBox id="tb5" columns="30" runat="server" /> </form> </body> </html>
ການເພີ່ມ script
ເວລາທີ່ການສະເໜີຟອມແບບຈະຖືກປະຕິບັດ, ຂໍ້ຄວາມ ແລະ ການປະກັນຄວາມຄິດຕາມ TextBox ຈະຖືກດຳເນີນໂດຍ script server. ການສະເໜີຟອມແບບຈະຖືກປະຕິບັດຜ່ານການຄຳສັ່ງຄວາມຄິດຕາມ Button ຫຼື ເວລາທີ່ຜູ້ນຳໃຊ້ປ່ຽນຄວາມຄິດຕາມ TextBox:
ໃນຄວາມຄິດຕາມລາຍການດັ່ງລຽງນີ້,ພວກເຮົາໄດ້ສະເໜີ ການສະແດງ TextBox ຄວາມຄິດຕາມ .aspx ຄວາມຄິດຕາມ Button ແລະ Label ຄວາມຄິດຕາມ. ເວລາທີ່ຄະດີປະຕິບັດຢູ່ທີ່ຄະດີປະຕິບັດຄວາມຄິດຕາມ Button, submit subprocedure ຈະຖືກດຳເນີນ. submit subprocedure ຈະຂຽນຄວາມຄິດຕາມ Label ຄວາມຄິດຕາມ:
<script runat="server"> Sub submit(sender As Object, e As EventArgs) lbl1.Text="Your name is " & txt1.Text End Sub </script> <html> <body> <form runat="server"> ເຂົ້າເມືອງຂອງທ່ານ: <asp:TextBox id="txt1" runat="server" /> <asp:Button OnClick="submit" Text="Submit" runat="server" /> <p><asp:Label id="lbl1" runat="server" /></p> </form> </body> </html>
ໃນຄວາມຍິງລຽງລັງດັ່ງກ່າວ, ພວກເຮົາຖືກກະກຽມໃນເອສເພັກສາຍ .aspx ເພື່ອກະກຽມ TextBox ຄວາມຄວຍ ແລະ Label ຄວາມຍິງ. ເມື່ອທ່ານປ່ຽນຄວາມຂອງ TextBox ແລະຄົງປາກົດຢູ່ກາງ TextBox, change ລູກອົງການຈະຖືກດຳເນີນ. change ລູກອົງການຈະຂຽນຄວາມທີ່ Label:
<script runat="server"> Sub change(sender As Object, e As EventArgs) lbl1.Text="You changed text to " & txt1.Text End Sub </script> <html> <body> <form runat="server"> ເຂົ້າເມືອງຂອງທ່ານ: <asp:TextBox id="txt1" runat="server" text="Hello World!" ontextchanged="change" autopostback="true"/> <p><asp:Label id="lbl1" runat="server" /></p> </form> </body> </html>
- ຫນ້າຫນັງ WebForms ViewState
- ຫນ້າຫນັງ WebForms Button