How to Make ASP. NET respond to the keyboard

Source: Internet
Author: User

081217

Another way is to add style = "display: none;" to the button ;"

Http://topic.csdn.net/u/20081217/15/064c4a7d-8189-4648-a7e1-0d99e60f4c36.html

Another question was raised. To hide the code generated by button. Directly setting it to visible = false is as follows:

  1. <Input type = "hidden" name = "_ eventvalidation" id = "_ eventvalidation" value = "/wewagka94slagls0blrbspgcnzaq9b96g6xk5qxbfoy1i + k"/>

Therefore, use the following method.

  1. <Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click" Height = "0px" width = "0px"/>

Someone asked me on the forum today. I tried it and succeeded. The friend gave me a full score. Well, record it and ask again.

Http://topic.csdn.net/u/20081208/09/5f9c15d5-b605-47a3-86f6-aafd09242801.html

Http://topic.csdn.net/u/20081217/13/5293b3a8-2e3b-4268-b433-d26705374270.html? Seed = 554615676

Front-end

  1. <% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "test_default" %>
  2. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  4. <Head runat = "server">
  5. <Title> how to enable ASP. NET to respond to the keyboard </title>
  6. <SCRIPT type = "text/JavaScript">
  7. Function entertextbox ()
  8. {
  9. If (event. keycode = 13 & document. All ["textbox1"]. value! = "")
  10. {
  11. Event. keycode = 9;
  12. Event. returnvalue = false;
  13. Document. All ["button1"]. Click ();
  14. }
  15. }
  16. </SCRIPT>
  17. </Head>
  18. <Body onkeypress = "Return entertextbox ()">
  19. <Form ID = "form1" runat = "server">
  20. <Div>
  21. <Asp: textbox id = "textbox1" runat = "server"> </ASP: textbox>
  22. <Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click"/>
  23. </Div>
  24. </Form>
  25. </Body>
  26. </Html>

Background

  1. Using system;
  2. Using system. Data;
  3. Using system. configuration;
  4. Using system. collections;
  5. Using system. Web;
  6. Using system. Web. Security;
  7. Using system. Web. UI;
  8. Using system. Web. UI. webcontrols;
  9. Using system. Web. UI. webcontrols. webparts;
  10. Using system. Web. UI. htmlcontrols;
  11. Public partial class test_default: system. Web. UI. Page
  12. {
  13. Protected void page_load (Object sender, eventargs E)
  14. {
  15. }
  16. Protected void button#click (Object sender, eventargs E)
  17. {
  18. Response. Write ("Press ENTER ");
  19. }
  20. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.