locked
Using Wizard varibles in Contact Us email body RRS feed

  • Question

  • User-614851559 posted

    I'm using a wizard to collect "contact us" information to send in an email (thanks to the Scott Mitchell video on this site). The body of the email should include the many textbox and checkbox inputs entered by the users, such as tbLastName.Text, tbFirstName.Text, tbStreetAddress.Text, etc, plus check box cbInterest1.(property? enabled?), cbInterest2.??? etc.

     I'm formatting the body of the email as a string, such as:

    Dim MyBody As String

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf &

                     "Last Name: " & tbLastName.Text & vbCrLF &

                      "Interest 1: " & cbInterest1.enabled??  

                      and so on, for all of my varibles collected

    However, I get the error message over my tbxxx.Text entries "Reference to a non-shared member requires an object reference." Unfortunately, my VB skills are such that I am clueless on how to solve this, even after reading the help on this message and seaching many forums.

    My questions:

    1. Is this the right approach or is there a better way to solve this problem?

    2. If this is a good approach, how do I deal with the "Reference to a non-shared member requires an object reference" comment?

    3. What property of the checkbox to I use to see if the checkbox is checked?

    Thanks,

    Deborah

    Monday, November 24, 2008 4:58 PM

Answers

  • User1006193418 posted

    I'm formatting the body of the email as a string, such as:

    Dim MyBody As String

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf &
                    "Last Name: " & tbLastName.Text & vbCrLF &
                    "Interest 1: " & cbInterest1.enabled??  

                    and so on, for all of my varibles collected

    Thanks,

    Deborah

    Hi Deborah,

    I wonder did you set the string above in several lines? If so, you may need to add the "_" at the end of every line like this: 

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf & _
             "Last Name: " & tbLastName.Text & vbCrLf & _
             "..."

    To the question below,

    What property of the checkbox to I use to see if the checkbox is checked?

    There is a good syntax in VB.Net: IIf(Expression, TruePart, FalsePart).

    Try this code: 

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf & _
             "Last Name: " & tbLastName.Text & vbCrLf & _
             "Interest 1:" & IIf(cbInterest1.Enabled,"ture","false") & _
             "Interest 2:" & IIf(cbInterest2.Enabled,"ture","false") & _
             "..."

    And to handle the error message "Reference to a non-shared member requires an object reference", we may need some more of your codes for it seems like the error didn't occure to the MyBody.

    Best Regards,
    Shenqging Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 24, 2008 11:10 PM
  • User1006193418 posted

    Hi Deborah,

    Sorry for the late. I have tested your codes and it seems to be the problem is caused by the mistake of using Page class.

    Let's look at the beginning of your VB.Net codes. You added this before the function: 

    Partial Class _Default
           Inherits System.Web.UI.Page

    However, it is not needed in the Code-Inline mode ASP.Net page. Let me explain it more clearly:

    The ASP.Net Framework (and Visual Web Developer) enables you to create two different types of ASP.Net pages. You can create both single-file and two-file ASP.NET pages. In a single-file ASP.Net page, a single file contains both the page code and page controls. The page code is contained in a <script runat=”server”> tag. As an alternative to a single-file ASP.NET page, you can create a two-file ASP.NET page. A two-file ASP.NET page is normally referred to as a code-behind page. In a code-behind page, the page code is contained in a separate file.

    Here, I quote a paasge from the book 'ASP.Net 3.5 Unleashed' by Stephen Walther, in which the 'single-file ASP.NET pages' is what I said Code-Inline mode before, and 'two-file ASP.NET pages' is named Code-Behind mode.

    A simple Code-Inline mode page is something like the example below: 

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            lblServerTime.Text = DateTime.Now.ToString()
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>First Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Welcome to ASP.NET 3.5! The current date and time is:
            <asp:Label ID="lblServerTime" runat="server" />
        </div>
        </form>
    </body>
    </html>

    And below is the Code-Behind mode reaching the same achievement:

    .asp page 

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="WebApplication1.WebForm2" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Welcome to ASP.NET 3.5! The current date and time is:
            <asp:Label ID="lblServerTime" runat="server" />
        </div>
        </form>
    </body>
    </html>
    .asp.vb page
    Public Partial Class WebForm2
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            lblServerTime.Text = DateTime.Now.ToString()
        End Sub
    
    End Class

    You can see in the second demo, we used "Public Partial Class WebForm2" which is not in the first one.

    So, delete these codes in your page and the issue will be solved. 

    <script runat="server">
    
        'cut these two lines
        Partial Class _Default
            Inherits System.Web.UI.Page
    
        ...
    
        'cut this line as well
        End Class
    
        ...
    
    </script>

    Some more articles helping to understand Code-Inline and Code-Behind is suggested:

    http://www.codinghorror.com/blog/archives/000174.html

    http://www.eggheadcafe.com/articles/20030518.asp

    http://www.codeproject.com/KB/aspnet/InlineCodeVSCodeBehind.aspx

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 26, 2008 6:00 AM

All replies

  • User1006193418 posted

    I'm formatting the body of the email as a string, such as:

    Dim MyBody As String

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf &
                    "Last Name: " & tbLastName.Text & vbCrLF &
                    "Interest 1: " & cbInterest1.enabled??  

                    and so on, for all of my varibles collected

    Thanks,

    Deborah

    Hi Deborah,

    I wonder did you set the string above in several lines? If so, you may need to add the "_" at the end of every line like this: 

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf & _
             "Last Name: " & tbLastName.Text & vbCrLf & _
             "..."

    To the question below,

    What property of the checkbox to I use to see if the checkbox is checked?

    There is a good syntax in VB.Net: IIf(Expression, TruePart, FalsePart).

    Try this code: 

    MyBody = "First Name: " & tbFirstName.Text & vbCrLf & _
             "Last Name: " & tbLastName.Text & vbCrLf & _
             "Interest 1:" & IIf(cbInterest1.Enabled,"ture","false") & _
             "Interest 2:" & IIf(cbInterest2.Enabled,"ture","false") & _
             "..."

    And to handle the error message "Reference to a non-shared member requires an object reference", we may need some more of your codes for it seems like the error didn't occure to the MyBody.

    Best Regards,
    Shenqging Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 24, 2008 11:10 PM
  • User-614851559 posted

    Thanks for the hint on the checkbox, so I am partially there. However, I keep getting the "Reference to a non-shared member requires an object reference" error.

    I wonder if it has anything to do with the fact that all these text boxes and checkboxes are in pages of a wizard? Intellisense tells me that there is something for each variable like this:

    tbLastName0

    so I wonder if that is so me sort of clue? If so, I don't know how to use it.

    Here is my code so far, but I get the blue squiggly line under each textbox and checkbox reference with the error "Reference ..."

     Dim MyBody As String
                MyBody = "Required Information" & vbCrLf & _
                "First Name: " & tbFirstName.Text & vbCrLf & _
                "Last Name: " & tbLastName.Text & vbCrLf & _
                "Email: " & tbEmail.Text & vbCrLf & _
                "Optional Information" & vbCrLf & _
                "Street: " & tbStreet.Text & vbCrLf & _
                "State: " & tbState.Text & vbCrLf & _
                "Zip: " & tbZip.Text & vbCrLf & _
                "Interests" & _
                "Volunteer Opportunities: " & IIf(cbVolunteerOpportunities.Enabled, "true", "false") & vbCrLf & _
                "Court Program: " & IIf(cbCourtProgram.Enabled, "true", "false") & vbCrLf & _
                "Item Donation: " & IIf(cbItemDonation.Enabled, "true", "false") & vbCrLf & _
                "WVC: " & IIf(cbWVC.Enabled, "true", "false") & vbCrLf & _
                "CVIA: " & IIf(cbCVIA.Enabled, "true", "false") & vbCrLf & _
                "DOVIA: " & IIf(cbDOVIA.Enabled, "true", "false") & vbCrLf & _
                "Volunteer Recognition: " & IIf(cbVolunteerRecognition.Enabled, "true", "false") & vbCrLf & _
                "Heart of Gold Award: " & IIf(cbHeartofGoldAward.Enabled, "true", "false") & vbCrLf & _
                "Heart of Gold Scholarship: " & IIf(cbHeartofGoldScholarship.Enabled, "true", "false") & vbCrLf & _
                "Agency Registration: " & IIf(cbAgencyRegistration.Enabled, "true", "false") & vbCrLf & _
                "Comments" & vbCrLf & _
                tbComments.Text           
                
                msgMail.Body = MyBody
                
    Thank you for your help on this.
    Tuesday, November 25, 2008 5:06 AM
  • User1006193418 posted

    Hi dpschwartz,

    Could you post your HTML codes of the whole Wizard control?

    Or, have a try to use FindControl method. 

    <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0">
        <WizardSteps>
            <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </asp:WizardStep>
            <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
                <asp:CheckBox ID="CheckBox1" runat="server" Text="CheckBox1" />
            </asp:WizardStep>
        </WizardSteps>
    </asp:Wizard>
    Then, use this kind of way to get the TextBox. 
    Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
        Dim myTxtBox As TextBox = CType(Wizard1.FindControl("TextBox1"), TextBox)
        Response.Write(myTxtBox.Text)
    
    End Sub

    Best Regards,
    Shengqing Yang

     

    Tuesday, November 25, 2008 5:29 AM
  • User-614851559 posted

    Hi Shengqing Yang,

     I tried the "find control" method to get to the textbox, still the same error for Wizard1.

    Here is my entire page (in case I am missing something obvious):

     

    <%@ Page Title="The Volunteer Center: Join Email List" Language="VB" MasterPageFile="~/Default.master" %>
    <%@ Register TagPrefix="Club" TagName="WebContent" Src="~/UserControls/WebContent.ascx" %>
    <%@ Import Namespace = "System.Net.Mail" %>
    
    
    <script runat="server">
    
    
        Partial Class _Default
            Inherits System.Web.UI.Page
    
            Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs)
                
                'Create the mail message
                Dim msgMail As New MailMessage()
                
                'Set the addresses
                msgMail.From = New MailAddress("user2@company.org")
                msgMail.To.Add("user@company.net")
    
                'This is the subject of the email
                msgMail.Subject = "UCanHelp site request"
                
                'This is the body of the email
                
                Dim MyBody As String
                MyBody = "Required Information" & vbCrLf & _
                "First Name: " & tbFirstName.Text & vbCrLf & _
                "Last Name: " & tbLastName.Text & vbCrLf & _
                "Email: " & tbEmail.Text & vbCrLf & _
                "Optional Information" & vbCrLf & _
                "Street: " & tbStreet.Text & vbCrLf & _
                "State: " & tbState.Text & vbCrLf & _
                "Zip: " & tbZip.Text & vbCrLf & _
                "Interests" & _
                "Volunteer Opportunities: " & CStr(IIf(cbVolunteerOpportunities.Enabled, "Interest", " ")) & vbCrLf & _
                "Court Program: " & CStr(IIf(cbCourtProgram.Enabled, "Interest", " ")) & vbCrLf & _
                "Item Donation: " & CStr(IIf(cbItemDonation.Enabled, "Interest", " ")) & vbCrLf & _
                "WVC: " & CStr(IIf(cbWVC.Enabled, "Interest", " ")) & vbCrLf & _
                "CVIA: " & CStr(IIf(cbCVIA.Enabled, "Interest", " ")) & vbCrLf & _
                "DOVIA: " & CStr(IIf(cbDOVIA.Enabled, "Interest", " ")) & vbCrLf & _
                "Volunteer Recognition: " & CStr(IIf(cbVolunteerRecognition.Enabled, "Interest", " ")) & vbCrLf & _
                "Heart of Gold Award: " & CStr(IIf(cbHeartofGoldAward.Enabled, "Interest", " ")) & vbCrLf & _
                "Heart of Gold Scholarship: " & CStr(IIf(cbHeartofGoldScholarship.Enabled, "Interest", " ")) & vbCrLf & _
                "Agency Registration: " & CStr(IIf(cbAgencyRegistration.Enabled, "Interest", " ")) & vbCrLf & _
                "Comments" & vbCrLf & _
                tbComments.Text()
                
                msgMail.Body = MyBody
                msgMail.IsBodyHtml = True
             
                'Send the mail message
                Dim smtp As New SmtpClient(ClubStarterKit.Web.Settings.MailServer())
                Dim a As New Net.NetworkCredential(ClubStarterKit.Web.Settings.MailUsername(), ClubStarterKit.Web.Settings.MailPassword())
                smtp.UseDefaultCredentials = False
                smtp.Credentials = a
                smtp.Send(msgMail)       
            End Sub
    
            
        End Class
      
        Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
            If tbComments.Text.Length > 1000 Then
                args.IsValid = False
            Else
                args.IsValid = True
            End If
        End Sub
    </script>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">  
        <div id="TVCcontent">
           <h1>Join Our Email List</h1>
            
                <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="3" Height="237px" 
                    Width="600px" CellPadding="5">
                    <StepStyle VerticalAlign="Top" />
                    <WizardSteps>
                        <asp:WizardStep runat="server" Title="Contact Information">
                            <table cellpadding="5" style="width: 100%">
                                <tr>
                                    <td>
                                        Your First Name</td>
                                    <td>
                                        <asp:TextBox ID="tbFirstName0" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                            ControlToValidate="tbFirstName" ErrorMessage="Please enter your first name.">*</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Your Last Name</td>
                                    <td>
                                        <asp:TextBox ID="tbLastName0" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                            ControlToValidate="tbLastName" ErrorMessage="Please enter your last name.">*</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Your Email</td>
                                    <td>
                                        <asp:TextBox ID="tbEmail0" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                                            ControlToValidate="tbEmail" ErrorMessage="Please enter your email address.">*</asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                                            ControlToValidate="tbEmail" ErrorMessage="Please enter a valid email address." 
                                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td colspan="2">
                                        <asp:ValidationSummary ID="ValidationSummary3" runat="server" />
                                    </td>
                                </tr>
                            </table>
                        </asp:WizardStep>
                        <asp:WizardStep runat="server" Title="Optional Information">
                            <table cellpadding="5" style="width: 100%">
                                <tr>
                                    <td>
                                        Street Address</td>
                                    <td>
                                        <asp:TextBox ID="tbStreet" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td>
                                        City</td>
                                    <td>
                                        <asp:TextBox ID="tbCity" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td>
                                        State</td>
                                    <td>
                                        <asp:TextBox ID="tbState" runat="server" MaxLength="2" Width="25px"></asp:TextBox>
                                    </td>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td>
                                        Zip</td>
                                    <td>
                                        <asp:TextBox ID="tbZip" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                            ControlToValidate="tbZip" ErrorMessage="Please enter a valid zip code." 
                                            ValidationExpression="\d{5}(-\d{4})?">*</asp:RegularExpressionValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Phone</td>
                                    <td>
                                        <asp:TextBox ID="tbPhone" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                                            ControlToValidate="tbPhone" 
                                            ErrorMessage="Please enter a phone as (nnn) nnn-nnnn.">*</asp:RegularExpressionValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td colspan="2">
                                        <asp:ValidationSummary ID="ValidationSummary2" runat="server" />
                                    </td>
                                </tr>
                            </table>
                        </asp:WizardStep>
                        <asp:WizardStep runat="server" Title="Interests &amp; Comments">
                            <h3>Please check your specific interests below (you can also leave blank)<br /></h3>
                            <table style="width: 100%">
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbVolunteerOpportunities" runat="server" />
                                    </td>
                                    <td>
                                        Volunteer Opportunities</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbAgencyRegistration" runat="server" />
                                    </td>
                                    <td>
                                        Agency Registration</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbCourtProgram" runat="server" />
                                    </td>
                                    <td>
                                        Court Program</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbItemDonation" runat="server" />
                                    </td>
                                    <td>
                                        Item Donation Program</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbWVC" runat="server" />
                                    </td>
                                    <td>
                                        Workplace Volunteer Council (WVC)</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbCVIA" runat="server" />
                                    </td>
                                    <td>
                                        Community Volunteers in Action (CVIA)</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbDOVIA" runat="server" />
                                    </td>
                                    <td>
                                        Directors of Volunteers in Agencies (DOVIA)</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbVolunteerRecognition" runat="server" />
                                    </td>
                                    <td>
                                        Volunteer Recognition Days</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbHeartofGoldAward" runat="server" />
                                    </td>
                                    <td>
                                        Heart of Gold Award</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:CheckBox ID="cbHeartofGoldScholarship" runat="server" />
                                    </td>
                                    <td>
                                        Heart of Gold Scholarship Award</td>
                                </tr>
                            </table>
                            <h3>
                                Enter any additional comments or questions:</h3>
                            <p>
                                (no more than 1000 characters)</p>
                            <asp:TextBox ID="tbComments" runat="server" MaxLength="1000" Rows="5" 
                                TextMode="MultiLine" Width="400px"></asp:TextBox>
                            <br />
                            <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                ControlToValidate="tbComments" 
                                ErrorMessage="No more than 1000 characters are allowed, please." 
                                ClientValidationFunction="ValidateComments"></asp:CustomValidator>
                        </asp:WizardStep>
                        <asp:WizardStep runat="server" StepType="Finish" Title="Summary">
                            <table cellpadding="5" style="width: 100%">
                                <tr>
                                    <td>
                                        Your First Name</td>
                                    <td>
                                        <asp:TextBox ID="tbFirstName" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                            ControlToValidate="tbFirstName" ErrorMessage="Please enter your first name.">*</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Your Last Name</td>
                                    <td>
                                        <asp:TextBox ID="tbLastName" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                            ControlToValidate="tbLastName" ErrorMessage="Please enter your last name.">*</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Your Email</td>
                                    <td>
                                        <asp:TextBox ID="tbEmail" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                            ControlToValidate="tbEmail" ErrorMessage="Please enter your email address.">*</asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                            ControlToValidate="tbEmail" ErrorMessage="Please enter a valid email address." 
                                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td colspan="2">
                                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                                    </td>
                                </tr>
                            </table>
                        </asp:WizardStep>
                        <asp:WizardStep runat="server" StepType="Complete" Title="Complete">
                            Thank you for your interest in The Volunteer Center.
                            <br />
                            <br />
                            We will get back to you soon.
                        </asp:WizardStep>
                    </WizardSteps>
                    <SideBarStyle BackColor="#F3930A" VerticalAlign="Top" Width="150px" />
                </asp:Wizard>
            
            <p>&nbsp;</p> 
    	</div>
    
    </asp:Content>
    
    

     

    Thank you for y our help on this. I have been stuck for a while on this.

    Deborah

     

    Tuesday, November 25, 2008 7:00 AM
  • User1006193418 posted

    Hi Deborah,

    Sorry for the late. I have tested your codes and it seems to be the problem is caused by the mistake of using Page class.

    Let's look at the beginning of your VB.Net codes. You added this before the function: 

    Partial Class _Default
           Inherits System.Web.UI.Page

    However, it is not needed in the Code-Inline mode ASP.Net page. Let me explain it more clearly:

    The ASP.Net Framework (and Visual Web Developer) enables you to create two different types of ASP.Net pages. You can create both single-file and two-file ASP.NET pages. In a single-file ASP.Net page, a single file contains both the page code and page controls. The page code is contained in a <script runat=”server”> tag. As an alternative to a single-file ASP.NET page, you can create a two-file ASP.NET page. A two-file ASP.NET page is normally referred to as a code-behind page. In a code-behind page, the page code is contained in a separate file.

    Here, I quote a paasge from the book 'ASP.Net 3.5 Unleashed' by Stephen Walther, in which the 'single-file ASP.NET pages' is what I said Code-Inline mode before, and 'two-file ASP.NET pages' is named Code-Behind mode.

    A simple Code-Inline mode page is something like the example below: 

    <%@ Page Language="VB" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            lblServerTime.Text = DateTime.Now.ToString()
        End Sub
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>First Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Welcome to ASP.NET 3.5! The current date and time is:
            <asp:Label ID="lblServerTime" runat="server" />
        </div>
        </form>
    </body>
    </html>

    And below is the Code-Behind mode reaching the same achievement:

    .asp page 

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="WebApplication1.WebForm2" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            Welcome to ASP.NET 3.5! The current date and time is:
            <asp:Label ID="lblServerTime" runat="server" />
        </div>
        </form>
    </body>
    </html>
    .asp.vb page
    Public Partial Class WebForm2
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            lblServerTime.Text = DateTime.Now.ToString()
        End Sub
    
    End Class

    You can see in the second demo, we used "Public Partial Class WebForm2" which is not in the first one.

    So, delete these codes in your page and the issue will be solved. 

    <script runat="server">
    
        'cut these two lines
        Partial Class _Default
            Inherits System.Web.UI.Page
    
        ...
    
        'cut this line as well
        End Class
    
        ...
    
    </script>

    Some more articles helping to understand Code-Inline and Code-Behind is suggested:

    http://www.codinghorror.com/blog/archives/000174.html

    http://www.eggheadcafe.com/articles/20030518.asp

    http://www.codeproject.com/KB/aspnet/InlineCodeVSCodeBehind.aspx

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 26, 2008 6:00 AM
  • User-614851559 posted

    Thank you. I never would have figured this out in a million years. I wonder how those lines of code got on my page, but that is a mystery I will keep for another day.

    I'll look at the articles, too. I keep trying to learn and it is so helpful when you point me in the right direction.

    You are a miracle worker!

    Deborah

    Wednesday, November 26, 2008 2:11 PM
  • User1006193418 posted

    Thank you. I never would have figured this out in a million years. I wonder how those lines of code got on my page, but that is a mystery I will keep for another day.

    I'll look at the articles, too. I keep trying to learn and it is so helpful when you point me in the right direction.

    You are a miracle worker!

    Deborah

    Hi,

    Really glad to be helpful[:)]!

    Regards,
    Shengqing Yang

    Wednesday, November 26, 2008 9:33 PM