2017-07-31 3 views
0

これは私がこれを実装したいユーザーコントロールのページエラーレンダリングコントロール。サーバブロックはよく

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

<b>Information about <%@ this.UserName %></b><br /><br /> 

<%@ this.UserName %> is <%@ this.UserAge %> years old and lives in <%@ this.UserCountry %> 

コントローラCSファイル

public partial class UserInfoBoxControl : System.Web.UI.UserControl 
{ 
    private string userName; 
    private int userAge; 
    private string userCountry; 

    public string UserName 
    { 
     get { return userName; } 
     set { userName = value; } 
    } 

    public int UserAge 
    { 
     get { return userAge; } 
     set { userAge = value; } 
    } 

    public string UserCountry 
    { 
     get { return userCountry; } 
     set { userCountry = value; } 
    } 

    protected void Page_Load(object sender, EventArgs e) 
    { 


    } 
} 

Webフォームで形成されていません。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %> 
<%@ Register TagPrefix="My" TagName="UserInfoBoxControl" src="~/UserInfoBoxControl.ascx" %> 
<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
    <br /><br /> 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> 
    <br /><br /> 
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> 
     <asp:ListItem>No one</asp:ListItem> 
     <asp:ListItem>World</asp:ListItem> 
     <asp:ListItem>Universe</asp:ListItem> 
    </asp:DropDownList> 
    <br /><br /> 
    <My:UserInfoBoxControl runat="server" ID="MyUserInfoBoxControl" /> 
</div> 
</form> 
</body> 
</html> 

取得エラー エラーレンダリングコントロール:Myuserinfoboxcontrol サーバブロックは、現在も形成されています。

私は自分のWebフォーム上のユーザーコントロールを実装したいが、私はこのエラーを取得しています

それを是正するためにどのようになっていません。助けが必要。おかげ

+0

私はWebApplication3.UserInfoBoxControlの継承といくつかの問題があると思います。あなたの質問にコードと完全なエラーメッセージを含める – StefanE

+0

@StefanEはあなたに私を助けることができます –

+0

あなたが何を頼んでいるかわからない、私はあなたが私が上に何を助けることができるとあなたの質問を更新する必要があることを繰り返すさらに – StefanE

答えて

0

私はこの推測:

<b>Information about <%@ this.UserName %></b><br /><br /> 

<%@ this.UserName %> is <%@ this.UserAge %> years old and lives in <%@ 
this.UserCountry %> 

は次のようになります。

<b>Information about <%= this.UserName %></b><br /><br /> 

<%= this.UserName %> is <%= this.UserAge %> years old and lives in <%= 
this.UserCountry %> 
関連する問題