怎么样防止页面刷新???
我用gridview控件,用到了其中的select功能,每当选择一行时页面都自动刷新,
滚动条都跑到最上面去,怎么解决???
[解决办法]
Ajax
或者用JS,为Select按钮添加JS事件,return false
[解决办法]
?
Ajax来不及学了,再说改动的太多;
加个UpdatePanel就行了
为Select按钮添加JS事件,return false,这样就取不到gridview中行里的数据了吧
还有什么好办法?多谢
Gv.Focus()
[解决办法]
你的GridView 应该在一个Table或者DIV种吧,直接在最外层加入 <UpdatePanel> <div> <GridView id= "GridView1 "/> </div> </UpdatePanel> 就ok了!记住一定要把Ajax引进来啊!不然报错!在网上搜搜吧!
[解决办法]
protected void Page_Load(object sender, EventArgs e)
{
Page.SmartNavigation = true;
}
[解决办法]
private bool _refreshState;
private bool _isRefresh;
/// <summary>
/// 判断页面是否提交后再次刷新,用法同IsPostBack
/// </summary>
public bool IsRefresh
{
get{return _isRefresh;}
}
protected override void LoadViewState(object savedState)
{
object[] AllStates = (object[])savedState;
base.LoadViewState(AllStates[0]);
_refreshState = Convert.ToBoolean(AllStates[1]);
_isRefresh = _refreshState == (Session[ "__ISREFRESH "] == null ? false : (bool)Session[ "__ISREFRESH "]);
}
protected override object SaveViewState()
{
Session[ "__ISREFRESH "] = _refreshState;
object[] AllStates = new object[2];
AllStates[0] = base.SaveViewState();
AllStates[1] = !_refreshState;
return AllStates;
}