首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

网页在ADSL下网状态上刷新太慢 ,会不会因为有4个DropDownList的影响

2012-12-23 
网页在ADSL上网状态下刷新太慢 ,会不会因为有4个DropDownList的影响我这个网页,如果用户是光纤,倒刷新速度

网页在ADSL上网状态下刷新太慢 ,会不会因为有4个DropDownList的影响
我这个网页,如果用户是光纤,倒刷新速度还可以的,但是用户假如是ADSL的话,就明显慢了,对此我加入了ajax技术,但是依然慢, 不知道是不是因为网页上有4个DropDownList的影响.请大家帮忙看一下,如何修改,会快一点

前台代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Qcount.aspx.cs" Inherits="Qc_Qcount" %>

<%@ Register src="../WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>

<!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">
        .style3
        {
            text-align: center;
            font-size: x-large;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <uc1:WebUserControl ID="WebUserControl1" runat="server" />
    <div>    
    </div>
    <div class="style3">
        大客户产品检验状况统计</div>
    <div>
    </div>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
         <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>     
     <div>
       
         <asp:UpdateProgress ID="UpdateProgress1" runat="server">
             <ProgressTemplate>
                 正在操作中,请稍候
             </ProgressTemplate>
         </asp:UpdateProgress>
       
        <br />    
        &nbsp;<asp:Button ID="AB" runat="server" onclick="AB_Click" Text="新建" 
             Width="79px" />
         &nbsp;&nbsp;
         &nbsp;&nbsp;<asp:Button ID="AC" runat="server"  Text="删除" 
             Width="79px" onclick="AC_Click" onclientclick="return confirm('是/否')" />
         &nbsp;&nbsp;
    </div>
    <div>
    


        <asp:Label ID="labid" runat="server"></asp:Label>
&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Label1" runat="server" Text="*日期"></asp:Label>
        <asp:TextBox ID="txtga51" runat="server" Width="77px"></asp:TextBox>
          <asp:Label ID="Label2" runat="server" Text="*加工点"></asp:Label>
        <asp:DropDownList ID="txtga02" runat="server"  
            style="margin-top: 0px" Width="124px" AutoPostBack="True" onselectedindexchanged="txtga02_SelectedIndexChanged" 
           >
        </asp:DropDownList>
        <asp:Label ID="Label6" runat="server" Text="*流水线"></asp:Label>
        <asp:DropDownList ID="txtga03" runat="server"  
            style="margin-top: 0px" Width="150px" 
           >
        </asp:DropDownList>
              <asp:Label ID="Label3" runat="server" Text="*产品"></asp:Label>
        <asp:DropDownList ID="txtga01" runat="server" 
             Width="124px" AutoPostBack="True" 
            onselectedindexchanged="txtga01_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:Label ID="Label4" runat="server" Text="*生产数量"></asp:Label>
        <asp:TextBox ID="txtga91" runat="server" Width="114px"></asp:TextBox>
    </div>
    <asp:Label ID="Label5" runat="server" Text="检验工序"></asp:Label>
    <asp:DropDownList ID="txtgb01" runat="server" AutoPostBack="True" Width="141px" 
        onselectedindexchanged="txtgb01_SelectedIndexChanged">
    </asp:DropDownList>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        Height="133px" onrowediting="GridView1_RowEditing" 
        onrowupdating="GridView1_RowUpdating" DataKeyNames="ID,gb01,gb02,gb03" 
        onrowcancelingedit="GridView1_RowCancelingEdit">
        <Columns>
            <asp:BoundField HeaderText="不良项目" DataField="gb04" />
            <asp:BoundField HeaderText="不良数量" DataField="gb92" />
            <asp:BoundField HeaderText="填写人" DataField="CreatePerson" />


            <asp:BoundField HeaderText="填写时间" DataField="CreatePersonDate" />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    </ContentTemplate>
        </asp:UpdatePanel>  
    </form>
</body>
</html>

后台代码如下:

public partial class Qc_Qcount : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            droplisttext();//下拉框的值
            Maticsoft.Model.AYONGHU mma = (Maticsoft.Model.AYONGHU)Session["ayonghu"];
            ViewState["name"] = mma.NAME;
        }
    }
    private void droplisttext()//改变下拉框的值
    {
        //求得下拉框的参数
        Maticsoft.BLL.Apm bll = new Maticsoft.BLL.Apm();
        DataTable idt;
        idt = bll.GetAllList().Tables[0];
        ViewState["dt"] = idt;
        //加工点
        DataView dv1 = new DataView(idt);
        dv1.RowFilter = ("parentcode='35'");
        txtga02.DataSource = dv1;
        txtga02.DataTextField = "cinvcname";
        txtga02.DataValueField = "no";
        txtga02.DataBind();
        txtga02.Items.Insert(0, new ListItem("", ""));
        txtga02.SelectedIndex = 0;
        //产品
        DataView dv2 = new DataView(idt);
        dv2.RowFilter = ("parentcode='3001'");
        txtga01.DataSource = dv2;
        txtga01.DataTextField = "cinvcname";
        txtga01.DataValueField = "no";
        txtga01.DataBind();
        //添加产品空白项        
        this.txtga01.Items.Insert(0, new ListItem("", ""));
        this.txtga01.SelectedIndex = 0;
        this.txtgb01.Items.Insert(0, new ListItem("", ""));
        this.txtgb01.SelectedIndex = 0;
    }



    protected void txtga01_SelectedIndexChanged(object sender, EventArgs e)//产品选择框
    {
       string ga51 = txtga51.Text.Trim();        
        string ga01value = txtga01.SelectedValue.ToString();
        string ga02value = txtga02.SelectedValue.ToString();
        string ga03value = txtga03.SelectedValue.ToString();
        //确认该记录是否已经存在有的话就返回值,
        //先做好参数
        SqlParameter[] parameters = {
new SqlParameter("@ga01", SqlDbType.VarChar,250),
new SqlParameter("@ga02", SqlDbType.VarChar,250),
    new SqlParameter("@ga03", SqlDbType.VarChar,250),
new SqlParameter("@ga51", SqlDbType.DateTime)};
        parameters[0].Value = ga01value;
        parameters[1].Value = ga02value;
        parameters[2].Value = ga03value;
        parameters[3].Value = ga51;
        //执行存储过程
        SqlDataReader sReader = Maticsoft.DBUtility.DbHelperSQL.RunProcedure("Qcountifinsert", parameters);
        sReader.Read();
        labid.Text = sReader[0].ToString();//对ID赋值
        txtga91.Text = sReader[1].ToString();   //对数量赋值,如果已经存在,就会直接显示    
        sReader.Close();
        //生成产品
        DataTable dt = (DataTable)ViewState["dt"];
        DataView dv2 = new DataView(dt);
        dv2.RowFilter = ("parentcode='" + txtga01.SelectedValue.ToString() + "'");
        txtgb01.DataSource = dv2;
        txtgb01.DataTextField = "cinvcname";
        txtgb01.DataValueField = "no";
        txtgb01.DataBind();
        //添加工序空白项        
        this.txtgb01.Items.Insert(0, new ListItem("", ""));
        this.txtgb01.SelectedIndex = 0;

    }
    protected void txtgb01_SelectedIndexChanged(object sender, EventArgs e)//检验工序选择
    {
        //判断必填项
        if (ifempty())
        {
            return;
        }
        if (labid.Text.Length == 0)
        {
            MessageBox.Show(this, "ID号没有,无法生成记录");


            return;
        }
        string qcountid = labid.Text;//获取主表id号
        string gb01 = txtgb01.SelectedValue.ToString();//大工序编号
        string gb02 = txtgb01.SelectedItem.Text;      
        //建立共用变量
        ViewState["id"] = qcountid;
        ViewState["gb01"] = gb01;
        ViewState["gb02"] = gb02;        
        showdata();//获取数据源,刷新数据
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        showdata();
    }
    private void showdata()//刷新数据
    {
        SqlParameter[] parameters = {
new SqlParameter("@gb91", SqlDbType.Int),
new SqlParameter("@gb01", SqlDbType.VarChar,250),
new SqlParameter("@gb02", SqlDbType.VarChar,250)};
        parameters[0].Value = int.Parse(ViewState["id"].ToString());
        parameters[1].Value = ViewState["gb01"].ToString();
        parameters[2].Value = ViewState["gb02"].ToString();       
        //执行存储过程
        DataSet ds = Maticsoft.DBUtility.DbHelperSQL.RunProcedure("Qcountbinsert", parameters, "Qcountb");
        GridView1.DataSource = ds.Tables["Qcountb"].DefaultView;
        GridView1.DataBind();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        showdata();
    }
     protected void txtga02_SelectedIndexChanged(object sender, EventArgs e)
    {
        //流水线
        DataView dv2 = new DataView((DataTable)ViewState["dt"]);
        dv2.RowFilter = ("parentcode='" + txtga02.SelectedValue.ToString() + "'");
        txtga03.DataSource = dv2;
        txtga03.DataTextField = "cinvcname";
        txtga03.DataValueField = "no";
        txtga03.DataBind();


    }
    protected void AC_Click(object sender, EventArgs e)//删除
    {
      }
}
[解决办法]
UpdatePanel与刷新整个页面的速度是一样的,因为机制就是回发,而不是纯粹基于前端javascript的ajax机制。

如果想开发用户体验好的网页应用,使用真正的前端ajax代码,或者silverlight等RIA机制。不论哪一种方式,都是纯粹地访问后台服务,而不是一遍遍去刷新页面(更不是去进行根本不需要的数据库查询操作),当然快啦。
[解决办法]

引用:
并且光纤的与ADSL的速度相差如此之大,说明了什么呢

2种网络传输机制不一样,ADSL虽说对上行和下行还可以,但是总线上分布不均匀的。所以ADSL慢也不奇怪
[解决办法]
你通过禁止VIEWSTATE这东西试试,另外尽量减少网络传输中不必要的流量
[解决办法]
程序有待优化。
[解决办法]
引用:
以下代码,因为 ViewState["dt"] 体积大,确实让ADSL用户刷新页面慢,我想放在cookies,但是它只能储存字符串,如果用Session保存,又担心用户多,又占用服务器资源, 如果不用 ViewState["dt"] 保存,每次去查询SQL SERVER, 又担心查询次数太多,占用太多服务器资源, 大家有没有好的办法呢?

//求得下拉框的参数
  Maticsoft.BLL……

总的需要取舍
[解决办法]
还是代码写的有问题
[解决办法]
引用:
引用:

还是代码写的有问题

给点创意吧,肯定有完美的解决办法.

真没有完美的方案,不是再次查询,就是存viewstate,再就是存session,总得有个取舍
不过你的网速得烂到什么程序会相差这么大。
另外找个工具吧aspx中的标签处理一下,去掉其中的空格和换行符也能省出一点流量来
[解决办法]
引用:
引用:

还是代码写的有问题

给点创意吧,肯定有完美的解决办法.

后台写的有问题,可以使用jquery重写(终极方法),少用客户端的 viewstate(必须做到的)。

如果LZ想问更具体的。只能具体分析了。
[解决办法]
初步判断,你的网页,另存为的html 大小接近1M。
[解决办法]
引用:
我改用cache感觉是要快很多,cache是好东西.

lz能说说cache具体改了什么么?

热点排行