<div style="width:367px; height:397px; position:absolute; top: 77px; left: 271px;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width:367px; height: 50px"></div><!--要显示的内容-->
<div style=" width:367px; height: 225px ;border:solid 1px;overflow-x:hidden;overflow-y:scroll">
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<div style="width:367px; height:30px;"><%# DataBinder.Eval(Container.DataItem,"neirong") %></div>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div style="height: 95px"><!--要发送的内容-->
<asp:TextBox ID="TextBox1" runat="server" Height="87px" Width="364px"></asp:TextBox>
</div>
<div style="height: 25px">
<asp:Button ID="Button1" runat="server" Text="发送" Width="121px"
onclick="Button1_Click1" />
</div>
</div>
为什么我发内容的时候还不是不能实现无刷新 显示内容呢
为什么我每次发内容 滚动条都移动上面去了
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width:367px; height: 50px"></div><!--要显示的内容-->
<div style=" width:367px; height: 225px ;border:solid 1px;overflow-x:hidden;overflow-y:scroll">
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<div style="width:367px; height:30px;"><%# DataBinder.Eval(Container.DataItem,"neirong") %></div>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div style="height: 95px"><!--要发送的内容-->
<asp:TextBox ID="TextBox1" runat="server" Height="87px" Width="364px"></asp:TextBox>
</div>
<div style="height: 25px">
<asp:Button ID="Button1" runat="server" Text="发送" Width="121px"
onclick="Button1_Click1" />
</div>
</div>
为什么我发内容的时候还不是不能实现无刷新 显示内容呢
为什么我每次发内容 滚动条都移动上面去了
建议使用其他Ajax方式。[如:ajaxpro]
如果你想使得排版好看点,可以在updatepanel放一个linkbutton,然后用服务器button与之关联,点击button实际就是点击linkbutton,实现无刷新。试试吧
<asp:Button ID="Button1" runat="server" Text="发送" Width="121px"
onclick="Button1_Click1" />
没放在updatepanel里。
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width: 367px; height: 50px">
</div>
<!--要显示的内容-->
<div style="width: 367px; height: 225px; border: solid 1px; overflow-x: hidden; overflow-y: scroll">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div style="width: 367px; height: 30px;">
<%# DataBinder.Eval(Container.DataItem,"neirong") %></div>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="OnClick" />
</Triggers>
</asp:UpdatePanel>
<div style="height: 95px">
<!--要发送的内容-->
<asp:TextBox ID="TextBox1" runat="server" Height="87px" Width="364px"></asp:TextBox>
</div>
<div style="height: 25px">
<asp:Button ID="Button1" runat="server" Text="发送" Width="121px" OnClick="Button1_Click1" />
</div>
</div>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="OnClick" />
</Triggers>
指定异步事件对象
提交完刷新页面里当然滚动条就上去啦,要想滚动条自动往下翻就在js里面去获取textarea的高度来手动定位,例如:TXTObject.scrollTop = TXTObject.scrollHeight;
2.提交前,记住滚动条的位置,提交后,控制页面滚动条,让它滚动到适当的位置。
我用不了啊
ajax+asp.net+mssql无刷新聊天室