繁体   English   中英

Insert.aspx.vb-将焦点设置为动态FormView中的控件

[英]Insert.aspx.vb - Set focus to control in dynamic FormView

我在ASP.NET LINQ to SQL网站中使用动态asp.net FormView(在Insert.aspx.vb中)遇到了一些麻烦。 这是FormView的代码...

        <asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" DefaultMode="Insert"
            OnItemCommand="FormView1_ItemCommand" OnItemInserted="FormView1_ItemInserted" RenderOuterTable="false">
            <InsertItemTemplate>
                <table id="detailsTable" class="DDDetailsTable" cellpadding="6">
                    <asp:DynamicEntity runat="server" Mode="Insert" />
                    <tr class="td">
                        <td colspan="2">
                            <asp:LinkButton runat="server" CommandName="Insert" Text="Insert" />
                            <asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                        </td>
                    </tr>
                </table>
            </InsertItemTemplate>
        </asp:FormView>

在浏览器中显示此表单时,将有5个用户输入控件和两个按钮(插入/取消)。 但是在代码中,除非有这行代码表示,否则我看不到对5个用户输入控件的任何引用...

    <asp:DynamicEntity runat="server" Mode="Insert" />

首先,假设这一行代码可以动态构建用户输入控件,我是否正确? 而且,我的实际问题-我需要在页面初始化时将Focus设置为这些输入中的第一个。 基本上,当有人选择插入一个新项目并发送到此页面时,我希望他们能够立即开始键入,而无需实际单击该文本框即可开始。 任何帮助将不胜感激?

我可以通过代码添加搜索字段来解决我的问题,然后在Page_Load事件中使用它...

    If table.DisplayName = "Employees" Then
        MultiSearchFieldSet.Visible = True
        txbMultiColumnSearch.Focus()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM