2011-12-21 7 views
1

私はUserControl内にDropDownListを持っています。DropDownListポストバックの問題

私の問題は、誰かがDDLから項目を選択すると、内部のusercontrolのテキストボックスを更新できるようにポストバックを起動する必要があることです。

自動ポストバックを使用すると、JSエラーが表示されます。「不可視、有効でない、またはフォーカスを受け付けないタイプのため、コントロールにフォーカスを移動できません。

誰でもこれに関するアイデアはありますか?

 <asp:MultiView ID="mvInvoiceItem" runat="server" ActiveViewIndex="0"> 
     <asp:View ID="vwInvoiceItemList" runat="server"> 
      <asp:LinkButton ID="btn_AddInvoiceItem" runat="server" 
       onclick="btn_AddInvoiceItem_Click">Add Part</asp:LinkButton> 
      <asp:GridView ID="gvwInvoiceItems" runat="server" AutoGenerateColumns="False" 
       EnableModelValidation="True" 
       OnRowCommand="gvwInvoiceItems_RowCommand" 
       DataKeyNames="Id" 
       AllowPaging="True" Width="750px" PageSize="3" > 
       <Columns> 
        <asp:BoundField DataField="Id" HeaderText="1" itemstyle-cssclass="invisibleColumn" > 
         <HeaderStyle CssClass="invisibleColumn" /> 
         <ItemStyle CssClass="invisibleColumn" /> 
        </asp:BoundField> 
        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> 
        <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" /> 
        <asp:BoundField DataField="IsSupplied" HeaderText="IsSupplied" SortExpression="IsSupplied" /> 
        <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" /> 
        <asp:BoundField DataField="Cost" HeaderText="Cost" SortExpression="Cost" /> 
        <asp:ButtonField ButtonType="Image" ImageUrl="~/Images/btn_select.png" CommandName="SelectRow" Text="Select" /> 
        <asp:ButtonField ButtonType="Image" ImageUrl="~/Images/btn_remove.png" CommandName="RemoveRow" Text="Remove" /> 
       </Columns> 
      </asp:GridView> 
     </asp:View> 
     <asp:View ID="vwInvoiceItemEdit" runat="server"> 
      <table> 
       <tr> 
        <td class="style2"> 
         <asp:Label ID="lbl_InvoiceItem" runat="server" 
          Text="Part.."></asp:Label> 
        </td> 
        <td> 
         <asp:DropDownList ID="dd_InvoiceItem" runat="server" 
          DataTextField="Name" DataValueField="Id" Width="215px" AutoPostBack="true" 
          OnSelectedIndexChanged="dd_InvoiceItem_SelectedIndexChanged"> 
         </asp:DropDownList> 
        </td> 
       </tr> 
       <tr> 
        <td class="style2"> 
         <asp:Label ID="lbl_InvoiceItemQuantity" runat="server" Text="Quantity.."></asp:Label> 
        </td> 
        <td width="250px"> 
         <asp:TextBox ID="txt_InvoiceItemQuantity" runat="server" MaxLength="100" 
          Width="190px" autocomplete="off"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td class="style2"> 
         <asp:Label ID="lbl_InvoiceItemPrice" runat="server" Text="Price.."></asp:Label> 
        </td> 
        <td width="250px"> 
         <asp:TextBox ID="txt_InvoiceItemPrice" runat="server" MaxLength="100" 
          Width="190px" autocomplete="off"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td class="style2"> 
         <asp:Label ID="lbl_InvoiceItemIsSupplied" runat="server" Text="Supplied.."></asp:Label> 
        </td> 
        <td> 
         <asp:CheckBox ID="chk_InvoiceItemIsSupplied" runat="server"/> 
        </td> 
       </tr> 
       <tr> 
        <td class="style2"> 
         <asp:Label ID="lbl_InvoiceItemCost" runat="server" Text="Cost.."></asp:Label> 
        </td> 
        <td width="250px"> 
         <asp:TextBox ID="txt_InvoiceItemCost" runat="server" MaxLength="100" 
          Width="190px" autocomplete="off"></asp:TextBox> 
        </td> 
       </tr> 
       <tr> 
        <td class="style2"> 
         &nbsp;</td> 
        <td align="right"> 
         <asp:ImageButton ID="btn_InvoiceItemSave" runat="server" 
          ImageUrl="~/Images/btn_save.png" onclick="btn_InvoiceItemSave_Click" /> 
         &nbsp;<asp:ImageButton ID="btn_InvoiceItemCancel" runat="server" 
          ImageUrl="~/Images/btn_cancel.png" onclick="btn_InvoiceItemCancel_Click" CausesValidation="false" /> 
        </td> 
       </tr> 
      </table> 
     </asp:View> 
    </asp:MultiView> 

インナーユーザーコントロールのためのPage_Loadでは何もありません...愚か私を運転する、それがInvoiceIdとPopulateGridを設定するための呼び出しに外部から初期化されます。

+0

これはASP.NETのエラーメッセージであり、ASP.NETではありません。 js関数を使ってフォーカスを手動でコントロールに設定しようとしていますか?そうであれば、フォーカスを得ることができるかどうかチェックする必要があります: 'if(element.type!=" hidden "&& element.style.display!=" none "&&!element.disabled){element.focus(); } ' –

+0

すべての' UpdatePanel's? – Bastardo

+0

もっとコードを投稿できますか?表示されていないコントロールで.Focus()を呼び出しているようです。 – Peter

答えて

2

これはかなり奇妙です。さらなる調査の際に、私は誰かが焦点の問題http://couldbedone.blogspot.com/2007/08/restoring-lost-focus-in-update-panel.html

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> 
    <Scripts> 
     <asp:ScriptReference Path="~/Resources/Focus.js" /> 
    </Scripts> 
</asp:ToolkitScriptManager> 

このホスティングASPXページ上のScriptManagerからJSに私の問題への解決策は、参照を削除してこのソリューションを実装していたことがわかりました。

関連する問題