快崩溃了,求各位大侠帮忙解决
先说说我的大致情况.
页面上有一个按钮 点击后在GridView里显示地址列表,GridView放在一个display:none的div里面,按钮的OnClientClick里面显示这个div,但是点击了之后页面虽然没有刷新,还是还是有刷新的效果.页面好像刷新了一样,div又恢复到隐藏状态了.
下面贴出部分代码:js:function showFloat() //根据屏幕的大小显示两个层
{
var range = getRange();
document.getElementById('doing').style.width = range.width + "px";
document.getElementById('doing').style.height = range.height + "px";
document.getElementById('doing').style.display = "block";
document.getElementById("divLogin").style.display="";
}
page:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" ChildrenAsTriggers="true" runat="server">
<ContentTemplate>
<asp:TextBox style=" border:solid 1px #ccc;" ID="tbKey" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" OnClientClick="showFloat()" OnClick="btSearch_Click" Text="搜 索" />(输入地址关键字搜索)<asp:Literal ID="ltMessage" runat="server"></asp:Literal>
<div id="doing" style="filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background-color:#000;width:100%;height:100%;z-index:1000;position: absolute;left:0;top:0;display:none;overflow: hidden;"></div>
<div id="divLogin" style="border:solid 10px #898989;background:#fff;padding:10px;width:780px;z-index:1001; position: absolute; display:none;top:50%; left:50%;margin:-200px 0 0 -400px;">
<div style="padding:3px 15px 3px 15px;text-align:left;vertical-align:middle;" >
<asp:GridView ID="grd" runat="server" AutoGenerateColumns="False" BackColor="#E0E0E0"
CellPadding="4" CellSpacing="1" CssClass="tableBorder" ForeColor="#333333"
GridLines="None" OnRowEditing="grd_RowEditing" Width="95%">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="Czwbh" HeaderText="出租屋编号">
<HeaderStyle CssClass="hid" />
<ItemStyle CssClass="hid" />
</asp:BoundField>
<asp:BoundField DataField="Czwdz" HeaderText="出租屋地址">
<HeaderStyle Width="80%" />
</asp:BoundField>
<asp:CommandField EditText="关联(点击处理)" HeaderText="关联地址" ShowEditButton="True">
<HeaderStyle Width="20%" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<div style="text-align:center;">
<cc1:AspNetPager id="pager" runat="server" AlwaysShow="false" CssClass="mypager" FirstPageText="第一页"
HorizontalAlign="right" LastPageText="最后一页" NextPageText="下一页" NumericButtonCount="8"
NumericButtonTextFormatString="[{0}]" OnPageChanged="pager_PageChanged" PageSize="8"
PagingButtonSpacing="10" PrevPageText="上一页" ShowCustomInfoSection="left" ShowInputBox="always"
SubmitButtonText="转到">
</cc1:AspNetPager>
<input id="BttCancel" type="button" value=" 关 闭 " onclick="ShowNo()" />
<div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
先说说我的大致情况.
页面上有一个按钮 点击后在GridView里显示地址列表,GridView放在一个display:none的div里面,按钮的OnClientClick里面显示这个div,但是点击了之后页面虽然没有刷新,还是还是有刷新的效果.页面好像刷新了一样,div又恢复到隐藏状态了.
下面贴出部分代码:js:function showFloat() //根据屏幕的大小显示两个层
{
var range = getRange();
document.getElementById('doing').style.width = range.width + "px";
document.getElementById('doing').style.height = range.height + "px";
document.getElementById('doing').style.display = "block";
document.getElementById("divLogin").style.display="";
}
page:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" ChildrenAsTriggers="true" runat="server">
<ContentTemplate>
<asp:TextBox style=" border:solid 1px #ccc;" ID="tbKey" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" OnClientClick="showFloat()" OnClick="btSearch_Click" Text="搜 索" />(输入地址关键字搜索)<asp:Literal ID="ltMessage" runat="server"></asp:Literal>
<div id="doing" style="filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background-color:#000;width:100%;height:100%;z-index:1000;position: absolute;left:0;top:0;display:none;overflow: hidden;"></div>
<div id="divLogin" style="border:solid 10px #898989;background:#fff;padding:10px;width:780px;z-index:1001; position: absolute; display:none;top:50%; left:50%;margin:-200px 0 0 -400px;">
<div style="padding:3px 15px 3px 15px;text-align:left;vertical-align:middle;" >
<asp:GridView ID="grd" runat="server" AutoGenerateColumns="False" BackColor="#E0E0E0"
CellPadding="4" CellSpacing="1" CssClass="tableBorder" ForeColor="#333333"
GridLines="None" OnRowEditing="grd_RowEditing" Width="95%">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="Czwbh" HeaderText="出租屋编号">
<HeaderStyle CssClass="hid" />
<ItemStyle CssClass="hid" />
</asp:BoundField>
<asp:BoundField DataField="Czwdz" HeaderText="出租屋地址">
<HeaderStyle Width="80%" />
</asp:BoundField>
<asp:CommandField EditText="关联(点击处理)" HeaderText="关联地址" ShowEditButton="True">
<HeaderStyle Width="20%" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<div style="text-align:center;">
<cc1:AspNetPager id="pager" runat="server" AlwaysShow="false" CssClass="mypager" FirstPageText="第一页"
HorizontalAlign="right" LastPageText="最后一页" NextPageText="下一页" NumericButtonCount="8"
NumericButtonTextFormatString="[{0}]" OnPageChanged="pager_PageChanged" PageSize="8"
PagingButtonSpacing="10" PrevPageText="上一页" ShowCustomInfoSection="left" ShowInputBox="always"
SubmitButtonText="转到">
</cc1:AspNetPager>
<input id="BttCancel" type="button" value=" 关 闭 " onclick="ShowNo()" />
<div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
解决方案 »
- 网站已经做好,凉了,还能优化?
- ObjectDataSource更新完数据后。数据控件没变化的,要手动刷新下才显示更新后的数据,怎么解决,
- datalist的一个稀奇问题。大家进来帮下忙
- 验证控件如何验证整形
- 高手请进,问题一直没有得到真正解决。请帮助新人。感激……
- 请教:关于DataGrid的显示问题,HELP……
- 在datalist中,怎么得到Container.DataItem的列名.(在线)
- 求救啊,VS10有问题啦,不会解决,急急急
- 高分请教-无法用vs.net2002在windows2003下用web共享方式创建web项目!
- 有关输入字符串的问题
- 动态生成RadioButton
- 关于排版的问题·
不行哦..div还是隐藏了,好像页面刷新了一样
这个按钮有两个事件,一个是客户端事件OnClientClick="showFloat()",一个是回传给服务端的事件OnClick="btSearch_Click",点击的时候,如果在OnClientClick没有return false拦截回传是会继续执行OnClick的事件,那当然会刷新了。
scriptmanager 貌似没放吧。
http://www.cnblogs.com/iuices/articles/2023412.html
等于你刷新页面一样,需要再次执行 js: showFloat 方法才能显示
或者就是吧updatepanel放在div.doing里面去
/// <summary>
/// 注册
/// </summary>
/// <param name="str"></param>
protected void SysInfo(string str)
{
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "SysInfo", str, true);
}调用:
SysInfo("showFloat();");
我本来是想要无刷新的效果,以为 updatepanel 是无刷新的..
结果是看似无刷新..其实还是刷新了...