Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 非常奇怪的问题:在aspx网页中提交后什么都没有发生_Asp.net_User Controls_Submit - Fatal编程技术网

Asp.net 非常奇怪的问题:在aspx网页中提交后什么都没有发生

Asp.net 非常奇怪的问题:在aspx网页中提交后什么都没有发生,asp.net,user-controls,submit,Asp.net,User Controls,Submit,测试环境:使用visual studio 2010的windows server 2008和使用visual studio 2008的windows vista 出现了以下不寻常的问题 我有一个用户控件和网站的控制将显示。 如果我检查控件的单选按钮并单击提交(也在ctrol中),则什么也不会发生。没有对服务器的请求,只是保持沉默 一切看起来都很好,很标准,但我找不到问题。请帮忙,因为这很烦人 usercontrol.ascx: <%@ Control Language="C#" AutoE

测试环境:使用visual studio 2010的windows server 2008和使用visual studio 2008的windows vista

出现了以下不寻常的问题

我有一个用户控件和网站的控制将显示。 如果我检查控件的单选按钮并单击提交(也在ctrol中),则什么也不会发生。没有对服务器的请求,只是保持沉默

一切看起来都很好,很标准,但我找不到问题。请帮忙,因为这很烦人

usercontrol.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EmployeeCategorizationControl.ascx.cs"
    Inherits="EmployeeCategorizationControl.EmployeeCategorizationControl" %>

<div id="categorizationOfEmployee">
<div>Categorization od Employee</div><br />
    <div id="firstCategory">
        <div style="float: left; width: 250px;">
            Is not a permanent employee</div>
        <div>
            <asp:RadioButtonList ID="YesNoIsNotPermanentEmployee" runat="server" RepeatDirection="Horizontal">
                <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="0"></asp:ListItem>
            </asp:RadioButtonList>
        </div>
    </div>
    <div id="secondCategory">
        <div style="float: left; width: 250px;">
            Is a fixed-term employee</div>
        <div>
            <asp:RadioButtonList ID="YesNoIsFixedTermEmployee" runat="server" RepeatDirection="Horizontal">
                <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="0"></asp:ListItem>
            </asp:RadioButtonList>
        </div>
    </div>
    <div id="thirdCategory">
        <div style="float: left;  width: 250px;">
            No external recruit</div>
        <div>
            <asp:RadioButtonList ID="YesNoExternalRecruit" runat="server" RepeatDirection="Horizontal">
                <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                <asp:ListItem Text="No" Value="0"></asp:ListItem>
            </asp:RadioButtonList>
        </div>
    </div>
    <div id="btCreate" style="margin-left: 200px; margin-top: 10px;">
        <asp:Button runat="server" Text="Create Checklist" ID="btCreateChecklist" />
    </div>
</div>
default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmployeeCategorizationControl._Default" %>
<%@ Register TagPrefix="UserControl" TagName="EmployeeCategorizationControl" Src="~/EmployeeCategorizationControl.ascx" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <UserControl:EmployeeCategorizationControl runat="server" />
    </div>
    </form>
</body>
</html>

如果您有
AutoEventWireup=“true”
则无需:

btCreateChecklist.Click += new EventHandler(btCreateChecklist_Click);

要么将其设置为
false
,要么删除上面的语句。

在我看来,这段代码工作得很好。我已经按原样将您的代码移植到本地应用程序中(更改名称空间以消除编译错误),并且它可以很好地发回。但是,您的事件除了设置两个变量(您不解释它们的作用或与之相关)之外什么都不做。你确定它没有执行回邮吗?此页面足够小,回发甚至可能不会导致屏幕闪烁(因为没有实际操作正在进行)。您应该在事件方法中加入一些可见的操作,例如更改标签的文本或按钮的
背景色

我把它放在default.aspx中,就像在control.ascx中一样。它自动连接给定名称的事件。
AutoEventWireup
仅适用于页面事件。btCreateChecklist。单击不是页面事件。它也不会对这种行为负责。如果这是问题,他的代码将生成2个单击事件。无法再现该问题(VS2008、.NET3.5、ASP.NET开发服务器)。这是唯一一个无法回发的页面/用户控件吗?您可以尝试以下方法:
btCreateChecklist.Click += new EventHandler(btCreateChecklist_Click);