Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.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 C#Web用户控件&引用;名称';控制名称';“在当前上下文中不存在”;_C#_Asp.net_Webusercontrol_Visual Web Developer 2010_Aspx User Control - Fatal编程技术网

无法识别ASP.NET C#Web用户控件&引用;名称';控制名称';“在当前上下文中不存在”;

无法识别ASP.NET C#Web用户控件&引用;名称';控制名称';“在当前上下文中不存在”;,c#,asp.net,webusercontrol,visual-web-developer-2010,aspx-user-control,C#,Asp.net,Webusercontrol,Visual Web Developer 2010,Aspx User Control,.aspx.cs文件中Today引用控件的行是1,它们抛出了错误;“当前上下文中不存在名称'TodayIs1'。我已经尝试了在前面的问题中提出的一些类似于我的建议。任何帮助都会很好,谢谢 .aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public

.aspx.cs文件中Today引用控件的行是1,它们抛出了错误;“当前上下文中不存在名称'TodayIs1'。我已经尝试了在前面的问题中提出的一些类似于我的建议。任何帮助都会很好,谢谢

.aspx.cs

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

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (RadioButtonList1.SelectedIndex == 0)
        {
            TodayIs1.Format = TodayIs.DateFormat.TheShortD;
        }
        else if (RadioButtonList1.SelectedIndex == 1)
        {
            TodayIs1.Format = TodayIs.DateFormat.LongD;
        }
    }
}
.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register TagPrefix="epm" TagName="TodayIs" Src="~/TodayIs.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>
    <epm:TodayIs ID="TodayIs1" runat="server" />
    </div>
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
        <asp:ListItem>Short Date</asp:ListItem>
        <asp:ListItem>Long Date</asp:ListItem>
    </asp:RadioButtonList>
    </form>
</body>
</html>
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TodayIs.ascx.cs" Inherits="WebUserControl" %>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
.ascx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register TagPrefix="epm" TagName="TodayIs" Src="~/TodayIs.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>
    <epm:TodayIs ID="TodayIs1" runat="server" />
    </div>
    <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
        <asp:ListItem>Short Date</asp:ListItem>
        <asp:ListItem>Long Date</asp:ListItem>
    </asp:RadioButtonList>
    </form>
</body>
</html>
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TodayIs.ascx.cs" Inherits="WebUserControl" %>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

这一行“public partial class WebUserControl:System.Web.UI.UserControl”是否应该改为“public partial class TodayIs:System.Web.UI.UserControl”谢谢!非常感谢!