用javascript操作asp.net TextBox伺服器控制項 外一篇

來源:互聯網
上載者:User
<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">    protected void Button1_Click(object sender, EventArgs e)    {        this.TextBox3.Visible = true;        this.TextBox3.Text = "name " + this.TextBox1.Text;        this.TextBox3.Text += "/r/n";        if (RadioButton1.Checked)        {            this.TextBox3.Text += "sex=男";        }        else        {            this.TextBox3.Text += "sex=女";        }        this.TextBox3.Text += "/r/n";        this.TextBox3.Text += "age="+this.TextBox2.Text;    }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>無標題頁</title><script language="javascript" type="text/javascript"><!--//只允許輸入數字,不允許輸入其它字母function TextBox2_onkeypress() {   //如果使用者按下斷行符號鍵,則提交表單   if(event.keyCode==13)   {     __doPostBack("Button1","");   }   if(event.keyCode>=48 && event.keyCode<=57 )   {         return true;   }   else   {     return false;   }     }// --></script></head><body>    <form id="form1" runat="server">    <div>        <table border="1" cellpadding="0" cellspacing="0">            <tr>                <td colspan="2" style="text-align: center">                    王瑗琿使用者註冊系統</td>            </tr>            <tr>                <td style="width: 100px">                    姓名</td>                <td style="width: 100px">                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>            </tr>            <tr>                <td style="width: 100px">                    性別</td>                <td style="width: 100px">                    <asp:RadioButton ID="RadioButton1" Checked="true" runat="server" Text="男" />                    <asp:RadioButton ID="RadioButton2" runat="server" Text="女" /></td>            </tr>            <tr>                <td style="width: 100px">                    年齡</td>                <td style="width: 100px">                    <asp:TextBox ID="TextBox2" onkeypress="return TextBox2_onkeypress()" runat="server"></asp:TextBox></td>            </tr>            <tr>                <td style="width: 100px">                </td>                <td style="width: 100px">                    <asp:Button ID="Button1" runat="server" Text="提交" OnClick="Button1_Click" /></td>            </tr>            <tr>                <td colspan="2" style="height: 75px">                    <asp:TextBox ID="TextBox3" runat="server" Height="65px" TextMode="MultiLine" Visible="False"                        Width="248px"></asp:TextBox></td>            </tr>        </table>        <br />        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="0px">        </asp:DropDownList></div>    </form></body></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.