【问题标题】:How to use jquery method in asp.net如何在asp.net中使用jquery方法
【发布时间】:2011-09-25 13:14:46
【问题描述】:

问:

我想知道如何在asp.net中使用这个jquery。(步骤)

$(...).scollTo( $('<%= txt_evaluateWeights.ClientID %>') )

我原来的问题是How to prevent the Focus() method from scrolling the page to the top

我的 aspx:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pnl_research" runat="server" CssClass="pnl">
                <div id="detailsDiv" align="center" style="width: 800px;">
                    <table border="0" width="98%">
                        <tr>
                            <td align="center">
                                <div class="grid" dir="rtl">
                                    <div class="grid" dir="rtl">
                                        <div class="rounded">
                                            <div class="top-outer">
                                                <div class="top-inner">
                                                    <div class="top">
                                                        <h2>
                                                            <asp:Label ID="Label35" runat="server" Text="Evaluation"></asp:Label></h2>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="mid-outer">
                                                <div class="mid-inner">
                                                    <div class="mid">
                                                        <asp:GridView Width="100%" ID="gv_Evaluation" CssClass="datatable" AllowSorting="True"
                                                            runat="server" AutoGenerateColumns="False" AllowPaging="True" GridLines="None"
                                                            OnRowDataBound="gv_Evaluation_RowDataBound">

                                                            <Columns>
                                                                <asp:TemplateField HeaderText="s">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblSerial" runat="server"></asp:Label></ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:BoundField HeaderText="activity type" DataField="activityType" />
                                                                <asp:BoundField HeaderText="weight" DataField="activityWeight" />
                                                                <asp:TemplateField HeaderText="eval">
                                                                    <ItemTemplate>
                                                                        <telerik:RadTextBox ID="txt_evaluateWeights" runat="server" AutoPostBack="True" OnTextChanged="txt_evaluateWeights_TextChanged">
                                                                        </telerik:RadTextBox>
                                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_evaluateWeights"
                                                                            Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator></ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:BoundField HeaderText="mine" DataField="activitySelf" />
                                                                <asp:BoundField HeaderText="head" DataField="activityBoss" />
                                                                <asp:BoundField HeaderText="dean" DataField="activityDean" />
                                                            </Columns>
                                                            <RowStyle VerticalAlign="Top" CssClass="row" />
                                                        </asp:GridView>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="bottom-outer">
                                                <div class="bottom-inner">
                                                    <div class="bottom">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>

我的 .cs:

protected void txt_evaluateWeights_TextChanged(object sender, EventArgs e)
    {

        calc();
        int index = ((System.Web.UI.WebControls.GridViewRow)(((RadTextBox)sender).Parent.NamingContainer)).DataItemIndex;

        ((RadTextBox)gv_Evaluation.Rows[index + 1].Cells[3].FindControl("txt_evaluateWeights")).Focus();


    }

【问题讨论】:

    标签: javascript jquery asp.net ajax jquery-plugins


    【解决方案1】:

    你需要使用 id 选择器,即前缀为 #:

    $(...).scollTo($('#<%= txt_evaluateWeights.ClientID %>'));
    

    【讨论】:

    • 我编辑了我的问题并添加了我的代码。请你帮我解决这个令人困惑的问题(How to prevent the Focus() method from scrolling the page to the top)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-06
    • 2011-03-10
    • 2018-04-15
    • 1970-01-01
    • 1970-01-01
    • 2014-09-02
    • 2010-10-25
    相关资源
    最近更新 更多