2016-10-10 14 views
1

テキストボックスのtextchangedイベントに問題があります。ボタンのクリックが私の.aspxのボタンイベントがテキスト変更後に誤って発生しました

<form id="form1" runat="server"> 
<div> 

</div> 
    <asp:Label ID="labelKodeDivisi" runat="server" style="z-index: 1; left: 62px; top: 57px; position: absolute" Text="labelKodeDivisi"></asp:Label> 
    <asp:Label ID="labelNamaDivisi" runat="server" style="z-index: 1; left: 62px; top: 85px; position: absolute" Text="labelNamaDivisi"></asp:Label> 
    <asp:Button ID="butLogout" runat="server" OnClick="butLogout_Click" style="z-index: 1; left: 682px; top: 40px; position: absolute" Text="Button" /> 
    <asp:TextBox ID="tbKode" runat="server" OnTextChanged="tbKode_TextChanged" style="z-index: 1; left: 71px; top: 127px; position: absolute"></asp:TextBox> 
</form> 

、ここで私のaspx.cs

public partial class FormDivisi2 : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 

    } 

    protected void butLogout_Click(object sender, EventArgs e) 
    { 
     labelKodeDivisi.Text = "123"; 
    } 

    protected void tbKode_TextChanged(object sender, EventArgs e) 
    { 
     labelNamaDivisi.Text = "555"; 
    } 
} 

いただきました、ここであまりにも

を解雇されたのはなぜ入力いくつかの文字列をしてエンターキーを押しますが、私は知りませんした後 私がテキストボックスtbKode、labelNamaDivisi.text 555にいくつかのテキストを入力するとき私が欲しいのは、私が欲しいのは、私が欲しいのは、私が欲しいのは、555に変更します。 labelKodeDivisiはchaではありませんnge。 labelKodeDivisiは唯一私がボタンbutLogout

+0

がhttp://stackoverflow.com/questions/4209903/asp-net-page-enter-key-causing-post-backを参照してみてください変更します – VDWWD

答えて

0

を打ったときにこの

$('input').keypress(function(event){ 
     if(event.keyCode==13) 
     { 
      event.preventDefault(); 

      } 
     }) 
関連する問題