2012-10-26 64 views
0

我正在調查我們網站的一個非常奇怪的問題。我們有一個textbox,它有一個OnTextChanged event。當事件被觸發時,我們會自動填充一些add'l文本框。這全是works fine in Firefox, Chrome, and Safari。 IE9然而,有一個問題。 In IE9,當事件被觸發時,頁面似乎正在做回發,但是在回發之後,ALL fields are blanked out。例如,如果我先輸入5個其他字段,則使用ontextchanged事件將數據輸入到文本框中,當我退出此文本框時,所有6個文本框值都將被清空。OnTextChanged Internet Explorer 9中的奇數問題

這裏是我的代碼:

<asp:TextBox runat="server" ID="txtDAWAgencyName" Width="340px" OnTextChanged="DawLookup" MaxLength="255"></asp:TextBox> 

protected void DAWLookup(object sender, EventArgs e) 
{ 
    if (Validation.ValidDAW(txtDAW.Text)) 
    { 
     Agency a = Agency.FetchByDAW(Convert.ToInt32(txtDAW.Text)); 

     if (a != null) 
     { 
      txtDAWAgencyName.Text = a.agencyName; 

      if (!string.IsNullOrEmpty(a.primaryContactId.ToString())) 
      { 
       MembershipUser mu = Membership.GetUser(a.primaryContactId); 
       if (mu != null) 
       { 
        GenericProfile gp = GenericProfile.FetchByUserId(a.primaryContactId); 
        if (gp != null) 
        { 
         txtDAWAgencyRep.Text = gp.contactName; 
         txtAgencyRepPhone.Text = gp.contactPhone; 
         txtAgencyRepEmail.Text = mu.UserName; 
        } 
       } 
      } 

     } 
    } 
} 

下面是關於這個問題的一些細節:

  • 在Chrome,火狐,Safari瀏覽器&成功的作品。
  • 只能在本地開發中在Internet Explorer中成功運行
  • 在服務器上的Internet Explorer中不起作用。
  • 有發生(only one postback)

這是最奇怪的事情沒有雙重autopostbacks。它在服務器上工作在all browsers EXCEPT internet explorer 9(在本地開發環境中工作)。任何想法可能是錯的?

回答

1

檢查頁面上的viewstate,啓用它。

如果您想保存自己的回發,還可以嘗試執行Ajax帖子。

我會推薦UpdatePanel或jQuery Postback。

+0

ajax方法工作。謝謝 – goalie35