0

In my website of Visual Studio 2008 (.NET 3.5), I have two textboxes in a page and there are two different onblur events for both. when first event is getting executed, the same time another is also getting executed. I don't get why it is. Here is code:

<asp:TextBox runat="server" ID="txtBK_CODE" Width="236px"
      CssClass="inp-form" MaxLength="8" onblur="javascript:SearchBK();"></asp:TextBox>
<asp:TextBox runat="server" ID="txtSL_CODE" Width="236px"
      CssClass="inp-form" MaxLength="8"onblur="javascript:SearchSL();"></asp:TextBox>

Now this functions will call webservice functions, below code:

 function SearchBK() {
      var textInput = document.getElementById('<%=txtBK_CODE.ClientID %>');
      ValidateBKSLCode.ValidateBK_CODE(textInput.value, OnSearchCompleteBK, OnErrorBK);
      loaded = true;
 }

 function OnErrorBK(result) {
      alert(result.get_message());
 }

 function OnSearchCompleteBK(result) {
      document.getElementById('<%=lblBK_NAME.ClientID %>').innerHTML = "";
      document.getElementById('<%=lblBK_NAME.ClientID %>').innerHTML = result;
 }

 function SearchSL() {
      var textInput = document.getElementById('<%=txtSL_CODE.ClientID %>');
      ValidateBKSLCode.ValidateSL_CODE(textInput.value, OnSearchCompleteSL, OnErrorSL);
      loaded = true;
 }
 function OnErrorSL(result) {
      alert(result.get_message());
 }

 function OnSearchCompleteSL(result) {
      document.getElementById('<%=lblSL_CODE.ClientID %>').innerHTML = "";
      document.getElementById('<%=lblSL_CODE.ClientID %>').innerHTML = result;
 }

I took the labels but not writing it here. Also when I press tab key in first textbox, both onblur events are getting fired but when pressing tab in second, only second function executes. (Used Javascript tags also but not writing here.) This page is in masterpage and I added service reference in scriptmanager in masterpage. Strange thing is in another website the works fine...! What am I missing or some silly mistake...?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
LeO
  • 35
  • 3
  • 14

1 Answers1

0

set asp.net textbox AutoPostBack= false and your asp.net textbox will function like an html textbox then your code should work fine