txtEmail や PanelSignUp などのコントロールは、コード ビハインドではアクセスできません。Web サイトを構築しようとすると、これらの行でエラーが発生します。
私のAcsxページコントロールのマークアップは以下の通りです
<%@ Control Language="VB" AutoEventWireup="false" Inherits="Articulate.userControls_emailSignUp" Codebehind="emailSignUp.ascx.vb" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:HiddenField ID="URL" runat="server" />
<asp:HiddenField ID="siteID" runat="server" />
<asp:HiddenField ID="siteName" runat="server" />
<asp:HiddenField ID="siteURL" runat="server" />
<a name="signUp"></a>
<div class="signup">
<asp:Panel ID="PanelSignUp" runat="server">
<div class="grid_8 alpha">
<h2>Keep me informed about product offers and latest news...</h2>
</div>
<div class="grid_8 omega">
<div class="block">
<p class="search">
<asp:TextBox ID="txtEmail" runat="server" class="signup text" ValidationGroup="es" TabIndex="1"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" ErrorMessage="Please enter your email address" ControlToValidate="txtEmail" SetFocusOnError="true" Display="None" ValidationGroup="es" TabIndex="2"/>
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" TargetControlID="rfvEmail" HighlightCssClass="testVal" />
<asp:RegularExpressionValidator ID="rgEmail" runat="server" ErrorMessage="Please enter a valid email address" ValidationExpression="<%$AppSettings:regExEmail%>" ControlToValidate="txtEmail" SetFocusOnError="true" Display="None" ValidationGroup="es" TabIndex="3"/>
<cc1:ValidatorCalloutExtender ID="vceEmail" runat="server" TargetControlID="rgEmail" HighlightCssClass="testVal" />
<asp:Button ID="BtnSignUp" runat="server" Text="Go >" CssClass="button blue" TabIndex="2" ValidationGroup="es" />
</p>
</div>
</div>
</asp:Panel>
エラーの発生元は次のとおりです。
Partial Class userControls_emailSignUp
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
txtEmail.Attributes.Add("value", "Your Email Address")
txtEmail.Attributes.Add("onfocus", "javascript:this.value='';")
End If
If Request.QueryString("emailSignUp") = "True" Then
PanelSignUp.Visible = False
PanelThankYou.Visible = True
End If
End Sub