user957863
user957863

Reputation: 325

asp.net calling code inline not working

In my code behind, I can do the following in the onload:

string x = Fmg.Cti.UI.Utilities.Classes.ResourceController.ReadResourceValue("Riblet", "Riblet_Chicklet1_Button_text");

This works without issue.

In my aspx page (I didn't remove the code from the onload), I put this:

<%= Fmg.Cti.UI.Utilities.Classes.ResourceController.ReadResourceValue("Riblet", "Riblet_Chicklet1_Button_text")%>

When I do, I got an error:

error CS0234: The type or namespace name 'Cti' does not exist in the namespace 'Fmg' (are you missing an assembly reference?)

I had this (or something quite similar) working. I don't know how I broke it.

Thanks again for your help.

Upvotes: 0

Views: 757

Answers (2)

Lawrence
Lawrence

Reputation: 447

Do you have that namespace imported? For asp.net you can do something like the following to make namespaces available for inline coding.

<%@ Import Namespace="Fmg.Cti.UI.Utilities.Classes" %>

You can make namespaces generally available to all of your asp.net pages for inline coding by adding the namespaces into the web.config

<system.web>
    <pages>
      <namespaces>
        ...
        <add namespace="Fmg.Cti.UI.Utilities.Classes" />
        ...
      </namespaces>
    </pages>
</system.web>

Upvotes: 0

thekip
thekip

Reputation: 3768

You need to register the assemblies you're using in your page as well (just like usings in your code behind). See Do I have to add "<%@ Register assembly=" to every page?

Upvotes: 2

Related Questions