开发者

asp.net postbacks won't fire

开发者 https://www.devze.com 2023-04-07 00:39 出处:网络
I\'ve made a simple ASP.net website and everything works fine on my computer. But on my colleague\'s computer no postbacks are fired although he uses the same OS (Win 7) AND the same browser as I do (

I've made a simple ASP.net website and everything works fine on my computer. But on my colleague's computer no postbacks are fired although he uses the same OS (Win 7) AND the same browser as I do (IE9).

I don't have any access to his computer right now which makes it kind of hard to debug. Does anybody know what could prevent postbacks on one computer although they work on a different one with the same browser? (I also tried it on a 3rd computer with different browser and OS and it worked there too)

//update: some code

The following code is one of the pages where the problem occures.

<%@ 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>

And the C#-Code:

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_开发者_JAVA百科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;
        }


    }
}


Check if your collegue got some script blocker installed, those can prevent postbacks since they are Javascript driven.


In case this helps someone:

I had something similar occur and it turned out that it was due to some validation controls on the page. They were for some hidden text boxes that were not actually visible and had no validation group specified. On one of the computers the errors were ignored and the postback worked, whereas on the second computer the postback failed due to validation errors. Because the text boxes were not currently visible, the problem was not immediately obvious.

Once I set up validation groups, the problem went away. I don't know why the behaviour was different on the two computers as both are running Chrome on Windows 10.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号