1

在后面的代码中无法访问 txtEmail 和 PanelSignUp 等控件。当我尝试构建网站时,我在这些方面遇到了错误。

我的 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
4

0 回答 0