469,917 Members | 1,644 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

CS0654: Method 'Chapter7.SingleBind.GetImageURL()' referenced without parentheses

Hello, I am currently working on an ASP.NET web application. When I compile my code behind the page, I do not get any errors ;however, when I attempt to view my code in a browser I get the error that is the title of this post. I am going to include a copy of my code behind the page, and my .aspx file code, can anyone help me out here? I am using Visual Studio.NET 2003, and my code behind the page is written in C#.

Here is the error as it appears in my browser:
Expand|Select|Wrap|Line Numbers
  1. Compilation Error 
  2. 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. 
  3.  
  4. Compiler Error Message: CS0654: Method 'Chapter7.SingleBind.GetImageURL()' referenced without parentheses
  5.  
  6. Source Error:
  7.  
  8.  
  9.  
  10. Line 16:                 Font-Names="Trebuchet MS" ForeColor="DarkSlateGray" Font-Size="Medium">Single Data Binding</asp:label><asp:label id="lblImageURL" style="Z-INDEX: 104; LEFT: 168px; POSITION: absolute; TOP: 132px"
  11. Line 17:                 runat="server" Font-Names="Trebuchet MS" Font-Size="X-Small" Width="100px" Height="30px"><%# ImageURL %>
  12. Line 18:             </asp:label><asp:textbox id=txtImageURL style="Z-INDEX: 110; LEFT: 167px; POSITION: absolute; TOP: 193px" runat="server" Width="104px" Text="<%# ImageURL %>"></asp:textbox><asp:image id=imgImageURL style="Z-INDEX: 108; LEFT: 166px; POSITION: absolute; TOP: 255px" runat="server" ImageUrl="<%# GetImageURL %>">
  13. Line 19:             </asp:image><asp:label id="Label4" style="Z-INDEX: 105; LEFT: 293px; POSITION: absolute; TOP: 131px" runat="server"
  14. Line 20:                 Font-Names="Trebuchet MS" Font-Size="X-Small" Width="184px" Height="38px">Displays the image name using an ASP.NET label control</asp:label><asp:label id="Label5" style="Z-INDEX: 106; LEFT: 293px; POSITION: absolute; TOP: 194px" runat="server"
  15.  
  16.  
  17.  
Here is my code behind the page:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11.  
  12. namespace Chapter7
  13. {
  14.     /// <summary>
  15.     /// Summary description for Products.
  16.     /// </summary>
  17.     public class SingleBind : System.Web.UI.Page
  18.     {
  19.         protected System.Web.UI.WebControls.Label lblImageURL;
  20.         protected System.Web.UI.WebControls.Image imgImageURL;
  21.         protected System.Web.UI.WebControls.Label Label4;
  22.         protected System.Web.UI.WebControls.Label Label5;
  23.         protected System.Web.UI.WebControls.Label Label7;
  24.         protected System.Web.UI.WebControls.TextBox txtImageURL;
  25.         //protected System.Web.UI.HtmlControls.HtmlInputText txtImageURL;
  26.         protected System.Web.UI.WebControls.Label Label1;
  27.  
  28.         protected string ImageURL 
  29.         {
  30.             get 
  31.             {
  32.                 return "logo.gif";
  33.             }
  34.         }
  35.         protected string GetImageURL()
  36.         {
  37.                 return "images/logo.gif";
  38.         }
  39.         private void Page_Load(object sender, System.EventArgs e)
  40.         {
  41.             Page.DataBind();
  42.             // Put user code to initialize the page here
  43.         }
  44.  
  45.         #region Web Form Designer generated code
  46.         override protected void OnInit(EventArgs e)
  47.         {
  48.             //
  49.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  50.             //
  51.             InitializeComponent();
  52.             base.OnInit(e);
  53.         }
  54.  
  55.         /// <summary>
  56.         /// Required method for Designer support - do not modify
  57.         /// the contents of this method with the code editor.
  58.         /// </summary>
  59.         private void InitializeComponent()
  60.         {    
  61.             this.Load += new System.EventHandler(this.Page_Load);
  62.  
  63.         }
  64.         #endregion
  65.     }
  66. }
  67.  
And here is my .aspx file in its entirity:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="c#" AutoEventWireup="false" Codebehind="SingleBind.aspx.cs" Inherits="Chapter7.SingleBind" %>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  3. <HTML>
  4.     <HEAD>
  5.         <title></title>
  6.         <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
  7.         <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
  8.         <meta content="JavaScript" name="vs_defaultClientScript">
  9.         <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  10.     </HEAD>
  11.     <body MS_POSITIONING="GridLayout">
  12.         <form id="Form1" method="post" runat="server">
  13.             <IMG style="Z-INDEX: 101; LEFT: 4px; POSITION: absolute; TOP: 6px" src="images/header2.jpg">
  14.             <IMG style="Z-INDEX: 102; LEFT: 21px; POSITION: absolute; TOP: 96px" src="images/menu.gif">&nbsp;&nbsp;
  15.             <asp:label id="Label1" style="Z-INDEX: 109; LEFT: 218px; POSITION: absolute; TOP: 71px" runat="server"
  16.                 Font-Names="Trebuchet MS" ForeColor="DarkSlateGray" Font-Size="Medium">Single Data Binding</asp:label><asp:label id="lblImageURL" style="Z-INDEX: 104; LEFT: 168px; POSITION: absolute; TOP: 132px"
  17.                 runat="server" Font-Names="Trebuchet MS" Font-Size="X-Small" Width="100px" Height="30px"><%# ImageURL %>
  18.             </asp:label><asp:textbox id=txtImageURL style="Z-INDEX: 110; LEFT: 167px; POSITION: absolute; TOP: 193px" runat="server" Width="104px" Text="<%# ImageURL %>"></asp:textbox><asp:image id=imgImageURL style="Z-INDEX: 108; LEFT: 166px; POSITION: absolute; TOP: 255px" runat="server" ImageUrl="<%# GetImageURL %>">
  19.             </asp:image><asp:label id="Label4" style="Z-INDEX: 105; LEFT: 293px; POSITION: absolute; TOP: 131px" runat="server"
  20.                 Font-Names="Trebuchet MS" Font-Size="X-Small" Width="184px" Height="38px">Displays the image name using an ASP.NET label control</asp:label><asp:label id="Label5" style="Z-INDEX: 106; LEFT: 293px; POSITION: absolute; TOP: 194px" runat="server"
  21.                 Font-Names="Trebuchet MS" Font-Size="X-Small" Width="192px" Height="40px">Display the image name in an ASP.NET textbox control</asp:label><asp:label id="Label7" style="Z-INDEX: 107; LEFT: 293px; POSITION: absolute; TOP: 254px" runat="server"
  22.                 Font-Names="Trebuchet MS" Font-Size="X-Small" Width="190px" Height="54px">Displays the image name in an ASP.NET image button control</asp:label></form>
  23.     </body>
  24. </HTML>
  25.  
Any help that could be provided in this area, would be greatly appreciated.
Feb 21 '07 #1
1 2457
I figured it out just now, I needed to remove the "get" statement in the C# code, and I needed to add "()" to "ImageURL" and "GetImageURL" in the code behind the page, and all of the databinding statments: < %ImageURL() %>
Feb 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

30 posts views Thread by Martin Bless | last post: by
4 posts views Thread by Steve | last post: by
28 posts views Thread by Howard Bryce | last post: by
19 posts views Thread by zzw8206262001 | last post: by
2 posts views Thread by Kevin Walzer | last post: by
11 posts views Thread by placid | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.