Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

When I preview my Register1.aspx (WebSite11) page through a browser I get the following source error:

Dim strEmail As Object

There is no line in my aspx or aspx.vb file that states: Dim strEmail As Object

Compiler Error Message: BC30260: 'strEmail' is already declared as 'Protected WithEvents strEmail As System.Web.UI.WebControls.TextBox' in this class.


The field I think the error is referring to is this:

<div class="form-group">
            <asp:Label runat="server" AssociatedControlID="strEmail" CssClass="col-md-2 control-label">Email</asp:Label>
            <div class="col-md-10">
  <asp:TextBox runat="server" ID="strEmail" TextMode="Email" CssClass="form-control" />
                <asp:RequiredFieldValidator runat="server" ControlToValidate="strEmail"
                    CssClass="text-danger" Display="Dynamic" ErrorMessage="The email field is required." />
               <asp:RegularExpressionValidator runat="server" ControlToValidate="strEmail" 
    CssClass="text-danger" Display="Dynamic" ErrorMessage="Please enter a valid email address."
    ValidationExpression="^.+@.+$" />
  
    </div>     
      </div>


I have changed the TextMode from strEmail to just Email, but it has made no difference. I'm not too sure what TextMode refers to.

Any help would be appreciated.
Posted

1 solution

change the id to something else
for example change
C#
ID="strEmail"

to
C#
ID="stringEmail"


you may need to change all the validators which pointing to this textbox and also in the code behind all references to new id.

Or refactor - rename below object to some other name. it will be easy for you
C#
Dim strEmail As Object

to
C#
Dim stringEmail As Object
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900