ユーザーコントロールをページに動的にロードしています。私は通常vb.netの人で、通常はうまくいくことができますが、これには困惑しています。ロードする前に、変数をページからコントロールに渡そうとしています。
コントロールを呼び出す場所は次のとおりです。
Control webUserControl = (Control)Page.LoadControl("~/controls/carousel-guards.ascx");
phGuardsList.Controls.Add(webUserControl);
carousel-guards.ascx に次のプロパティを追加しました。
public String PostCode
{
get
{
return this.PostCode;
}
set
{
this.PostCode = value;
}
}
しかし、私は webUserControl.PostCode を利用できないようです。
どんな助けでも本当に感謝します
編集 -もちろん、コントロールを参照する必要があります。愚かな私!ただし、carousel_guards で呼び出すことはできません。Error 96 The type or namespace name 'carousel_guards' could not be found (are you missing a using directive or an assembly reference?) C:\Development\Guards247\g247 Test\FindGuard.aspx.cs 197 13 g247 Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace g247_Test.controls
{
public partial class carousel_guards : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public String PostCode
{
get
{
return this.PostCode;
}
set
{
this.PostCode = value;
}
}
}
}