Q:
I wanna to know how to use this jquery in asp.net.(steps)
$(...).scollTo( $('<%= txt_evaluateWeights.ClientID %>') )
My original question is How to prevent the Focus() method from scrolling the page to the top
My 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>
My .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();
}
Well you need to use an id selector, i.e. prefix with #
:
$(...).scollTo($('#<%= txt_evaluateWeights.ClientID %>'));
精彩评论