locked
So I get this error message but I'm not sure why please help. RRS feed

Answers

  • User475983607 posted

    Basically, you are not using the Web Forms framework properly.  The Content placeholders hold dynamic web page content with the master page mantains a common layout.

    Please see the following tutorial to learn Web Forms.

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/introduction-and-overview

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 21, 2019 11:41 PM
  • User665608656 posted

    Hi Joe_p321,

    Based on your code, you are using a master page in you aspx page.

    After you reference the master page, in your current aspx page, you only need to insert html code to the corresponding content module .

    The default master page will have two ContentPlaceHolder, one is the head, which is used to put js code or css style.

    The other is ContentPlaceHolder1, which is used to store the html code content.

    Here is a master page:

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="WebApplication_Decemeber.Case.Site1" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
            </div>
        </form>
    </body>
    </html>

    In your aspx page, you need to put the css style into Content1 of ContentPlaceHolderID='head', and then put the following table and other html code into Content2 of ContentPlaceHolderID ='ContentPlaceHolder1'

    You don’t need to add any more tags like: <!DOCTYPE html> <head> <html> <body>.

    Here is the aspx page with master page based on your code:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Case/Site1.Master" AutoEventWireup="true" CodeBehind="ContentControls_1223_2162617.aspx.cs" Inherits="WebApplication_Decemeber.Case.ContentControls_1223_2162617" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style type="text/css">
            .auto-style6 {
                width: 296%;
            }
    
            .auto-style7 {
                width: 70px;
            }
    
            .auto-style8 {
                width: 315px;
            }
        </style>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <table class="auto-style6">
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblSurname" runat="server" Text="Surname"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtSurname" runat="server" Width="297px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblFirstName" runat="server" Text="FirstName"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtFirstName" runat="server" Width="295px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress1" runat="server" Text="Address1"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress1" runat="server" Width="294px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress2" runat="server" Text="Address2"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress2" runat="server" Width="293px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress3" runat="server" Text="Address3"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress3" runat="server" Width="291px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress4" runat="server" Text="Address4"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress4" runat="server" Width="292px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblPostcode" runat="server" Text="Postcode"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtPostcode" runat="server" Width="289px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblTelephoneNo" runat="server" Text="Telephone No"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtTelephoneNo" runat="server" Width="290px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Button ID="btnSubmitCustomer" runat="server"  Text="Submit" />
                </td>
                <td class="auto-style8">
                    <asp:Button ID="Button1" runat="server" Text="Clear" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [tblCustomer] WHERE [CustomerID] = @CustomerID" InsertCommand="INSERT INTO [tblCustomer] ([Surname], [FirstName], [Address1], [Address2], [Address3], [Address4], [Postcode], [Phone]) VALUES (@Surname, @FirstName, @Address1, @Address2, @Address3, @Address4, @Postcode, @Phone)" SelectCommand="SELECT * FROM [tblCustomer]" UpdateCommand="UPDATE [tblCustomer] SET [Surname] = @Surname, [FirstName] = @FirstName, [Address1] = @Address1, [Address2] = @Address2, [Address3] = @Address3, [Address4] = @Address4, [Postcode] = @Postcode, [Phone] = @Phone WHERE [CustomerID] = @CustomerID">
    <DeleteParameters>
    <asp:Parameter Name="CustomerID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
    <asp:ControlParameter ControlID="txtSurname" Name="Surname" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtFirstName" Name="FirstName" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress1" Name="Address1" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress2" Name="Address2" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress3" Name="Address3" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress3" Name="Address4" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtPostcode" Name="Postcode" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtTelephoneNo" Name="Phone" PropertyName="Text" Type="String" />
    </InsertParameters>
    <UpdateParameters>
    <asp:Parameter Name="Surname" Type="String" />
    <asp:Parameter Name="FirstName" Type="String" />
    <asp:Parameter Name="Address1" Type="String" />
    <asp:Parameter Name="Address2" Type="String" />
    <asp:Parameter Name="Address3" Type="String" />
    <asp:Parameter Name="Address4" Type="String" />
    <asp:Parameter Name="Postcode" Type="String" />
    <asp:Parameter Name="Phone" Type="String" />
    <asp:Parameter Name="CustomerID" Type="Int32" />
    </UpdateParameters>
    </asp:SqlDataSource> </td> </tr> </table> </asp:Content>

    Here is the result of this work demo:

    You can also refer to this link for more details about master page:

    Creating a Site-Wide Layout Using Master Pages (C#)

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 23, 2019 7:24 AM

All replies

  • User475983607 posted

    Basically, you are not using the Web Forms framework properly.  The Content placeholders hold dynamic web page content with the master page mantains a common layout.

    Please see the following tutorial to learn Web Forms.

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/introduction-and-overview

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 21, 2019 11:41 PM
  • User665608656 posted

    Hi Joe_p321,

    Based on your code, you are using a master page in you aspx page.

    After you reference the master page, in your current aspx page, you only need to insert html code to the corresponding content module .

    The default master page will have two ContentPlaceHolder, one is the head, which is used to put js code or css style.

    The other is ContentPlaceHolder1, which is used to store the html code content.

    Here is a master page:

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="WebApplication_Decemeber.Case.Site1" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
            </div>
        </form>
    </body>
    </html>

    In your aspx page, you need to put the css style into Content1 of ContentPlaceHolderID='head', and then put the following table and other html code into Content2 of ContentPlaceHolderID ='ContentPlaceHolder1'

    You don’t need to add any more tags like: <!DOCTYPE html> <head> <html> <body>.

    Here is the aspx page with master page based on your code:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Case/Site1.Master" AutoEventWireup="true" CodeBehind="ContentControls_1223_2162617.aspx.cs" Inherits="WebApplication_Decemeber.Case.ContentControls_1223_2162617" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style type="text/css">
            .auto-style6 {
                width: 296%;
            }
    
            .auto-style7 {
                width: 70px;
            }
    
            .auto-style8 {
                width: 315px;
            }
        </style>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <table class="auto-style6">
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblSurname" runat="server" Text="Surname"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtSurname" runat="server" Width="297px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblFirstName" runat="server" Text="FirstName"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtFirstName" runat="server" Width="295px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress1" runat="server" Text="Address1"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress1" runat="server" Width="294px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress2" runat="server" Text="Address2"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress2" runat="server" Width="293px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress3" runat="server" Text="Address3"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress3" runat="server" Width="291px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblAddress4" runat="server" Text="Address4"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtAddress4" runat="server" Width="292px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblPostcode" runat="server" Text="Postcode"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtPostcode" runat="server" Width="289px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Label ID="lblTelephoneNo" runat="server" Text="Telephone No"></asp:Label>
                </td>
                <td class="auto-style8">
                    <asp:TextBox ID="txtTelephoneNo" runat="server" Width="290px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    <asp:Button ID="btnSubmitCustomer" runat="server"  Text="Submit" />
                </td>
                <td class="auto-style8">
                    <asp:Button ID="Button1" runat="server" Text="Clear" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [tblCustomer] WHERE [CustomerID] = @CustomerID" InsertCommand="INSERT INTO [tblCustomer] ([Surname], [FirstName], [Address1], [Address2], [Address3], [Address4], [Postcode], [Phone]) VALUES (@Surname, @FirstName, @Address1, @Address2, @Address3, @Address4, @Postcode, @Phone)" SelectCommand="SELECT * FROM [tblCustomer]" UpdateCommand="UPDATE [tblCustomer] SET [Surname] = @Surname, [FirstName] = @FirstName, [Address1] = @Address1, [Address2] = @Address2, [Address3] = @Address3, [Address4] = @Address4, [Postcode] = @Postcode, [Phone] = @Phone WHERE [CustomerID] = @CustomerID">
    <DeleteParameters>
    <asp:Parameter Name="CustomerID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
    <asp:ControlParameter ControlID="txtSurname" Name="Surname" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtFirstName" Name="FirstName" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress1" Name="Address1" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress2" Name="Address2" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress3" Name="Address3" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtAddress3" Name="Address4" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtPostcode" Name="Postcode" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="txtTelephoneNo" Name="Phone" PropertyName="Text" Type="String" />
    </InsertParameters>
    <UpdateParameters>
    <asp:Parameter Name="Surname" Type="String" />
    <asp:Parameter Name="FirstName" Type="String" />
    <asp:Parameter Name="Address1" Type="String" />
    <asp:Parameter Name="Address2" Type="String" />
    <asp:Parameter Name="Address3" Type="String" />
    <asp:Parameter Name="Address4" Type="String" />
    <asp:Parameter Name="Postcode" Type="String" />
    <asp:Parameter Name="Phone" Type="String" />
    <asp:Parameter Name="CustomerID" Type="Int32" />
    </UpdateParameters>
    </asp:SqlDataSource> </td> </tr> </table> </asp:Content>

    Here is the result of this work demo:

    You can also refer to this link for more details about master page:

    Creating a Site-Wide Layout Using Master Pages (C#)

    Best Regards,

    YongQing.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 23, 2019 7:24 AM