Error :
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1061: 'AddressControl.AddressForm1' does not contain a definition for 'Street' and no extension method 'Street' accepting a first argument of type 'AddressControl.AddressForm1' could be found (are you missing a using directive or an assembly reference?) Source Error:
|
Line 8: protected void btnSubmit_Click(object Sender,EventArgs e)
Line 9: {
Line 10: ltlResult.Text = AddressForm1.Street;
Line 11: }
Line 12: </script>
|
Source File: c:\Users\ZENITHH\Documents\Visual Studio 2017\Projects\AddressControl\AddressControl\CheckOut.aspx Line: 10
The code for AddressForm Control . File name : AddresForm.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AddressForm.ascx.cs" Inherits="AddressControl.AddressForm1" %>
<script runat="server">
public string Title
{
get { return ltlTitle.Text; }
set { ltlTitle.Text = value; }
}
public string Street
{
get { return txtStreet.Text; }
set { txtStreet.Text = value; }
}
public string State
{
get { return txtState.Text; }
set { txtState.Text = value; }
}
</script>
<fieldset>
<legend>
<asp:Literal ID="ltlTitle" Text="Address Form" runat="server" />
</legend>
<div class="addressLabel">
<asp:Label id="lblstreet" Text="Street" runat="server" />
</div>
<div class="addressField">
<asp:TextBox ID="txtStreet" runat="server" />
<asp:RegularExpressionValidator ID="reqStreet" Text="(Required)" ControlToValidate="txtStreet" runat="server" />
<br class="clear" />
<div class="addressLabel">
<asp:Label ID="lblState" text="State" AccociatedControlID="txtState" runat ="server" />
<asp:TextBox ID="txtState" runat="server" />
<asp:RequiredFieldValidator ID="reqState" Text="(Required)" ControlToValidate="txtState" runat="server" />
</div>
</div>
</fieldset>
</script>
And the file that is using the contol file name :- Checkout.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CheckOut.aspx.cs" Inherits="AddressControl.CheckOut" %>
<%@ Register TagPrefix="User" TagName="AddressForm" Src="~/AddressForm.ascx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<script runat="server">
protected void btnSubmit_Click(object Sender,EventArgs e)
{
ltlResult.Text = AddressForm1.Street;
}
</script>
<head runat="server">
<title>Address Form</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<user:AddressForm ID="AddressForm1" title ="Billing Address" runat ="server" />
<br />
<asp:Button Id="btnSubmit" Text="Submit Form" onclick="btnSubmit_Click" runat="server" />
<asp:Literal ID="ltlResult" runat="server" />
</div>
</form>
</body>
</html>
Need to help to solve this .