enter image description here我之前尝试了很多解决方案,以防止页面滚动顶部在网格视图中的复选框被更改但没有人解决我的问题..请帮忙! 提前谢谢
(更新) - >
<asp:Panel ID="Panel2" runat="server" CssClass="Panel" GroupingText="<img src='Images/lightbulb.gif' /> Step 2: Seclect Threats to detect">
<%--<h1 style="text-align:right;padding-right:30px;position:absolute;right:40px;top:300px" > <asp:Label ID="lbl_cost" runat="server" Text="0 $" ></asp:Label></h1>--%>
<ajax:TabContainer ID="tc_thread_types" runat="server" AutoPostBack="true" Width="100%" CssClass="Tab" ActiveTabIndex="0">
<ajax:TabPanel ID="tab_mem_threads" runat="server" HeaderText="Member Threats" CssClass="Tab">
<ContentTemplate>
<div id="scrollDiv1" style="width: 100%; max-height: 400px; overflow: auto" >
<asp:GridView ID="gv_ThDetails_Mem" runat="server" CssClass="Grid"
Style="width: 100%; padding: 25px; margin-top: 10px; margin-bottom: 10px"
AutoGenerateColumns="False" OnRowDataBound="gv_ThDetails_mem_RowDataBound">
<Columns>
<asp:BoundField DataField="thread_id" HeaderText="Threat Id" />
<asp:BoundField DataField="thread_desc" HeaderText="Threat Description" />
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="ch_all_mem" runat="server" AutoPostBack="true" OnCheckedChanged="ch_all_mem_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<%--<asp:CheckBox ID="cb_includedThreat_mem1" Onclick='<%# "ShowCurrentTime(" +Eval("serial") + " );" %>' runat="server" />--%>
<asp:CheckBox ID="cb_includedThreat_mem" runat="server" AutoPostBack="true" OnCheckedChanged="cb_includedThreat_mem_CheckedChanged" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="serial" HeaderText="serial" Visible="false" />
</Columns>
</asp:GridView>
</div>
<script type="text/javascript">
//var prm = Sys.WebForms.PageRequestManager.getInstance();
//prm.add_beginRequest(beginRequest);
//function beginRequest() {
// prm._scrollPosition = null;
//}
</script>
</ContentTemplate>
</ajax:TabPanel>
</ajax:TabContainer>
protected void cb_includedThreat_mem_CheckedChanged(object sender, EventArgs e)
{
try
{
//up_frdSetup.Update();
CheckBox included = (CheckBox)sender;
//GridViewRow gr = (GridViewRow)included.Parent.Parent;
int count;
if (rbl_memType.SelectedIndex == -1)
{
included.Checked = false;
SystemMsg.fn_SetMessageProperties("U6", "You should select membership first!"); // casting
SystemMsg.Focus();
return;
}
if (Session["IsExpired"] != null && Session["IsExpired"].ToString().Equals("Y") && rbl_memType.SelectedValue.ToString().Equals("T"))
{
included.Checked = false;
ib_save.Enabled = false;
// ib_save.CssClass = "btn disabled";
ib_save.ToolTip = "Submit was disabled As your trial version was expired!";
SystemMsg.fn_SetMessageProperties("U6", "Your trial version was expired! Please select Preimuim Subscription Now!");
//lbl_cln_msg.Text = "Your trial version was expired! Please select Premium Subscription Now!";
//cln_msg.Style.Add("display", "normal");
return;
}
if (ViewState["cnt_th_mem"] == null)
{
count = 0;
}
else
{
count = int.Parse(ViewState["cnt_th_mem"].ToString());
}
if (included.Checked)
{
count++;
ViewState["cnt_th_mem"] = count;
}
else if (!included.Checked && count > 0)
{
count--;
ViewState["cnt_th_mem"] = count;
}
included.Focus();
if (rbl_memType.SelectedValue.ToString().Equals("T"))
{
int tot_cnt = fn_check_tot_checked_threads();
if (tot_cnt > 3)
{
included.Checked = false;
count--;
ViewState["cnt_th_mem"] = count;
//lbl_cln_msg.Text = "The Maximum allowed threats in trial membership is Three only!";
//cln_msg.Style.Add("display", "normal");
SystemMsg.fn_SetMessageProperties("U6", "The Maximum allowed threats in trial membership is Three only!");
SystemMsg.Focus();
return;
}
//lbl_cost.Text = "0$";
//ViewState["cnt_th_mem"] = 0;
}
else if (rbl_memType.SelectedValue.ToString().Equals("P"))
{
//lbl_cost.Text = (Double.Parse(Session["th_price"].ToString()) * count) + "$";
ViewState["cnt_th_mem"] = count;
}
//fn_checkIncluded_Mem_Threads();
CheckBox ch_all = gv_ThDetails_Mem.HeaderRow.FindControl("ch_all_mem") as CheckBox;
if (count == gv_ThDetails_Mem.Rows.Count)
{
ch_all.Checked = true;
}
else if (count == 0)
{
ch_all.Checked = false;
}
else
{
ch_all.Checked = false;
}
fn_check_tot_cost();
}
catch (System.IO.IOException eio)
{
SystemMsg.fn_SetMessageProperties("S1", eio.Message); // IO
SystemMsg.Focus();
return;
}
catch (NullReferenceException ex)
{
SystemMsg.fn_SetMessageProperties("S2", ex.Message); // NULL
SystemMsg.Focus();
return;
}
catch (SqlException sqlEx)
{
SystemMsg.fn_SetMessageProperties("S4", sqlEx.Message); // SQL
SystemMsg.Focus();
return;
}
catch (Exception exe)
{
SystemMsg.fn_SetMessageProperties("S0", exe.Message);
SystemMsg.Focus();
return;
}
}
提前感谢..
答案 0 :(得分:0)
将此内容放入页面指令&lt;%@ Page%&gt;
MaintainScrollPositionOnPostback = "true"
由于页面PostBack而发生。以上确保页面PostBack后滚动的位置。
或者将GridView
保留在div中并使用JavaScript
技巧执行此操作:Maintain Scroll Position in Div