繁体   English   中英

asp.net回发不会触发

[英]asp.net postbacks won't fire

我已经做了一个简单的ASP.net网站,并且在我的计算机上一切正常。 但是,虽然他使用与我相同的操作系统(Win 7)和相同的浏览器(IE9),但在我同事的计算机上没有触发任何回发。

我现在无法访问他的计算机,这使得调试起来有点困难。 有人知道什么可以阻止一台计算机上的回发,尽管它们可以在具有相同浏览器的另一台计算机上工作? (我还在具有不同浏览器和操作系统的第三台计算机上进行了尝试,并且在该计算机上也可以使用)

//更新:一些代码

以下代码是发生问题的页面之一。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewList.aspx.cs" Inherits="QAList.NewList" %>

<!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>Items</title>

    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

    <link href="qalist.css" rel="stylesheet" type="text/css" />

    <script src="lib/jquery-1.4.3.min.js" type="text/javascript"></script>
    <script src="lib/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="css/smoothness/jquery-ui-1.8.5.custom.css" type="text/css" media="screen" charset="utf-8" />

    <style type="text/css">

        input[disabled]
        {
            background-color:#888888;
        }

        .Filled 
        {
            width: 98%;
        }

        .Property
        {            margin-bottom: 0px;
        }

       .Date
        {
            /* this class is only used to indicate that the value is a DateTime value */
        }


        .PropertyTable td
        {
            border-bottom: 1px solid #D8D8D8;
            padding:1px;
            background-color:#F6F6F6;
        }

        .Suppler_style
        {
            color: #0000BB;
        }

    </style>

    <script type="text/javascript">

        $(function () {
            $(".Date").datepicker({ dateFormat: "yy/mm/dd" });
        });

    </script>

</head>
<body>

    <form id="form1" runat="server">



    <table style="width: 80%;" border="0" class="PropertyTable" cellspacing="0" cellpadding="0">
    <tr>
        <td style="width: 227px;">
            Project Number</td>
        <td>
            <asp:TextBox ID="ProjectNumber" runat="server" CssClass="Property" Width="200px"></asp:TextBox>
        &nbsp; <asp:Button ID="btApplyPnr" runat="server" Text="  apply  " 
                onclick="btApplyPnr_Click" />
        </td>
    </tr>
    <tr>
        <td>
            Contract No.</td>
        <td>
            <asp:DropDownList ID="ddContractNo" runat="server" AutoPostBack="True" 
                onselectedindexchanged="ContractNo_SelectedIndexChanged" 
                CssClass="Filled">
            </asp:DropDownList>
            <input type="hidden" class="Property" id="V_QA_PO_tp_listId" runat="server" />
            <input type="hidden" class="Property" id="V_QA_PO_tp_ID" runat="server" />
            <input type="hidden" class="Property" id="ContractNo" runat="server" />
        </td>
    </tr>
    <tr>
        <td>
            ITP No</td>
        <td>
            <asp:TextBox ID="ITPNo" runat="server" CssClass="Filled Property"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="Suppler_style">
            ITP Name</td>
        <td>
            <asp:TextBox ID="ITPName" runat="server" CssClass="Filled Property"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="Suppler_style">
            Status Delivery/Finish Date</td>
        <td>
            <asp:TextBox ID="StatusDeliveryFinishDate" runat="server" 
                CssClass="Filled Property Date"></asp:TextBox>
        </td>
    </tr>
    </table>


    </form>

</body>
</html>

和C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace QAList
{
    public partial class NewList : System.Web.UI.Page
    {

        private string current_contract = "0";
        private string current_pnr;

        protected void Page_Load(object sender, EventArgs e)
        {
            current_contract = ddContractNo.SelectedValue;
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            //load Contract Numbers
            ddContractNo.Items.Clear();
            ddContractNo.Items.Add(new ListItem("-", "0"));
            foreach (DataRow contract in DBAccess.Instance.getContractNumbers(current_pnr).Rows)
            {
                ddContractNo.Items.Add(new ListItem(contract["ProjectNumber"] + " - " + contract["ContractNo"] + " - " + contract["GoodsServicesSupplied"], contract["tp_listId"] + "_" + contract["tp_ID"]));
            }
            try
            {
                ddContractNo.SelectedValue = current_contract;
            }
            catch (ArgumentOutOfRangeException)
            {
                ddContractNo.SelectedValue = null;
                applyNewContractValue();
            }
        }

        protected void ContractNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            applyNewContractValue();
        }

        private void applyNewContractValue()
        {
            current_contract = ddContractNo.SelectedValue;
            if (!String.IsNullOrEmpty(current_contract) && current_contract != "0")
            {
                Guid tp_listId = new Guid(current_contract.Split('_')[0]);
                int tp_ID = Convert.ToInt32(current_contract.Split('_')[1]);
                DataRow row = DBAccess.Instance.getContractInfos(tp_listId, tp_ID);
                if (row == null)
                    return;
                ITPName.Text = row.IsNull("GoodsServicesSupplied") ? "" : row["GoodsServicesSupplied"].ToString();
                if (!row.IsNull("PlannedDeliveryexworks"))
                {
                    DateTime tmp = (DateTime)row["PlannedDeliveryexworks"];
                    StatusDeliveryFinishDate.Text = tmp.Year + "/" + fillZeros(tmp.Month, 2) + "/" + fillZeros(tmp.Day, 2);
                }
            }
            else
            {
                ITPName.Text = "";
            }
        }

        private string fillZeros(int nr, int min_length)
        {
            string res = nr.ToString();
            while (res.Length < min_length)
                res = "0" + res;
            return res;
        }

        protected void btApplyPnr_Click(object sender, EventArgs e)
        {
            current_pnr = ProjectNumber.Text;
        }


    }
}

检查您的同事是否安装了某些脚本阻止程序,由于它们是Javascript驱动的,因此可以防止回发。

如果这可以帮助某人:

我发生了类似的事情,事实证明这是由于页面上的某些验证控件所致。 它们用于一些实际上不可见且未指定验证组的隐藏文本框。 在其中一台计算机上,错误被忽略并且回发有效,而在第二台计算机上,由于验证错误,回发失败。 因为文本框当前不可见,所以问题不是立即显而易见。

设置验证组后,问题就消失了。 我不知道为什么这两台计算机上的行为不同,因为这两台计算机都在Windows 10上运行Chrome。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM