CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • CS1061: 'string' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'string' could be found

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    6251
  • Date Created
    Thursday, June 16, 2022
  • This Article Has been Viewed
    337 times
  • Short Desc
    CS1061: 'string' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'string' could be found
  • Details
    When testing an asp.net web application you may encounter the following error if your component is misnamed.
     

    CS1061: 'string' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
  • Recreate Issue
    The error is generated when asp.net component ID is misnamed.
    Example
    <asp:Label ID="LabelOne" runat="server" Text="Label"></asp:Label>
    And CodeFile or CodeBehind is this
    Label1.Text = "Page set to Upload!";
  • Resolve Issue
    As demonstrated above, the ID is LabelOne, but in CodeFile or CodeBehind, we have Label1 as the ID for the label.
    To correct the issue, ensure all component IDs match their corresponding CodeBehind source.
    <asp:Label ID="LabelOne" runat="server" Text="Label"></asp:Label>
    And CodeFile or CodeBehind is this
    LabelOne.Text = "Page set to Upload!";