小弟初用ajax框架
一个页面中用了updatepanel
updatepannel里是一个绑定了数据源的listbox和对此绑定的项的增删改操作按钮
但明明增加了数据或删除了数据,跳转到其它页面后再跳转回来时发现数据仍是未更改前的数据
自己设个断点调试了一下发现在跳回调用这个页面时,页面就没有更新了,
好像是在本地缓存了。。
请各位指教一下
一个页面中用了updatepanel
updatepannel里是一个绑定了数据源的listbox和对此绑定的项的增删改操作按钮
但明明增加了数据或删除了数据,跳转到其它页面后再跳转回来时发现数据仍是未更改前的数据
自己设个断点调试了一下发现在跳回调用这个页面时,页面就没有更新了,
好像是在本地缓存了。。
请各位指教一下
解决方案 »
- vs10 有没什么自带的实现遮罩效果~~~~~~急
- c#开发的webservice程序和数据库连接的问题!!
- 怎么去掉textbox边框的阴影?
- 求助:在主页面上验证信息后,立即显示在库所检索的内容.
- (在线等)关于JAVASCRIPT的一点问题,急!!!
- 请问你们都用什么工具编写ASP.NET
- 如何动态的定义变量的名称?
- 如何响应(实现)DataGird中ItemTemplate中的TextBox的TextChanged事件?
- asp.net用户权限的问题!~~~~~~~~~~~~~~~~
- 怎么样动态设置web服务的URL?
- csdn发表的帖子,发现写错了,不让自己改,又不让自己删,真是求生不得,求死不得
- 打搅下,问个asp的问题 下拉框显示的时候,为什么我在循环内再写个下拉,为什么显示不出来,请指教
然后我在page_load里写事件,然后设了断点,但跳到这个页面时,根本没有运行page_load代码
也就是这个请求没有回发,而是调用了本地的缓存
页面代码如下
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="companystand.aspx.cs" Inherits="companystand" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>××××</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#Layer1 {
position:absolute;
left:0px;
top:0px;
width:570px;
height:25px;
z-index:1;
}
#Layer2 {
position:absolute;
left:570px;
top:0px;
width:225px;
height:25px;
z-index:2;
}
#Layer3 {
position:absolute;
left:700px;
top:0px;
width:141px;
height:25px;
z-index:3;
}
#Layer4 {
position:absolute;
left:0px;
top:24px;
width:1000px;
height:150px;
z-index:4;
}
#Layer5 {
position:absolute;
left:0px;
top:25px;
width:110px;
height:125px;
z-index:5;
}
-->
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="Layer1">
<script language=javascript>
var flashURL="head.swf";
var flashWIDTH="570";
var flashHEIGHT="25";
</script> <script language=javascript src="include/flashframe.js"></script>
</div>
<div id="Layer4" style="left: 146px; width: 815px; top: 49px; height: 299px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:taxiConnectionString %>"
SelectCommand="SELECT * FROM [es]"></asp:SqlDataSource>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width: 572px; height: 244px; border-right: silver thin inset; border-top: silver thin inset; border-left: silver thin inset; border-bottom: silver thin inset;">
<tr>
<td colspan="2" style="height: 13px" background="images/chanpin.gif">
</td>
</tr>
<tr>
<td colspan="1" rowspan="4" valign="top">
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="es_title"
DataValueField="es_id" Height="195px" Width="346px" AutoPostBack="True" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" ></asp:ListBox></td>
<td rowspan="2" style="height: 90px; width: 205px;">
<asp:TextBox ID="TextBox1" runat="server" Height="112px" TextMode="MultiLine" Width="191px"></asp:TextBox></td>
</tr>
<tr>
</tr>
<tr>
<td style="font-size: 9pt; width: 205px; color: #004e98; height: 3px">
分值<asp:TextBox ID="TextBox2" runat="server" Width="102px"></asp:TextBox></td>
</tr>
<tr>
<td style="height: 35px; width: 205px;">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/add.gif" OnClick="ImageButton1_Click" />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/del.gif" OnClick="ImageButton2_Click" />
<asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/images/edit.gif" OnClick="ImageButton3_Click" /></td>
</tr>
<tr>
<td style="height: 15px" colspan="2" background="images/chanpin.gif">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="Layer5" style="left: 0px; top: 45px; width: 142px; height: 70px;">
<script language=javascript>
var flashURL="stand.swf";
var flashWIDTH="140";
var flashHEIGHT="60";
</script> <script language=javascript src="include/flashframe.js"></script></div>
</form>
</body>
</html>
C#代码如下
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class companystand : System.Web.UI.Page
{
SqlConnection userConnection = DB.GetConnetcion();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ListBox1.DataBind();
}
this.Label2.Text = Session["loginname"].ToString();
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.TextBox1.Text = this.ListBox1.SelectedItem.Text;
//取出分值
SqlCommand userCommand = new SqlCommand("select es_point from es where es_id= '" + this.ListBox1.SelectedItem.Value.ToString() + "'", userConnection);
userCommand.Connection.Open();//打开连接
this.TextBox2.Text = userCommand.ExecuteScalar().ToString();
userCommand.Connection.Close();//关闭连接
} //新增
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlCommand userCommand = new SqlCommand("exec insert_es_1 '"+this.TextBox1.Text+"','"+this.TextBox2.Text+"'", userConnection);
userCommand.Connection.Open();//打开连接
userCommand.ExecuteNonQuery();
userCommand.Connection.Close();//关闭连接
this.ListBox1.DataBind();
}
//删除
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
SqlCommand userCommand = new SqlCommand("exec delete_es_1 '"+this.ListBox1.SelectedItem.Value.ToString()+"'", userConnection);
userCommand.Connection.Open();//打开连接
userCommand.ExecuteNonQuery();
userCommand.Connection.Close();//关闭连接
this.ListBox1.DataBind();
}
//更新
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
SqlCommand userCommand = new SqlCommand("exec update_es_1 '"+this.ListBox1.SelectedItem.Value.ToString()+"','"+this.TextBox1.Text+"','"+this.TextBox2.Text+"'", userConnection);
userCommand.Connection.Open();//打开连接
userCommand.ExecuteNonQuery();
userCommand.Connection.Close();//关闭连接
this.ListBox1.DataBind();
}
}
<%@ OutputCache Duration= "1 " VaryByParam= "none " % >
嗯。用这个方法解决了问题。不知道各位还有没有什么好的建议
比如如果没有更改过这个页面就用原来缓存的以提高响应速度。
如果发生了更改就同步刷新页面?