Solved

asp.net call code inline

Posted on 2011-09-21
5
449 Views
Last Modified: 2012-05-12
I have a dll and function call that I can call in my code behind.  How do I do it inline?  In this example, it just returns a string.

This is how I can do it in the code behind now.  I can set the result string to a lable
using MyDom.Utilities.Classes;
string result = ResourceController.ReadResourceValue("file", "key");

I want to be able to do this inline like:
<%= ResourceController.ReadResourceValue("file", "key") %>
0
Comment
Question by:jackjohnson44
  • 2
  • 2
5 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 36575771
You're very close.

Either:
<%= MyDom.Utilities.Classes.ResourceController.ReadResourceValue("file", "key") %>

Open in new window


Or:
<!-- Top of Page Here -->
<%@ Imports Namespace="MyDom.Utilities.Classes" %>
<!-- The @Imports directive is equivelant to a "using" statement in code-behind, and must appear at top of file -->
<%= ResourceController.ReadResourceValue("file", "key") %>

Open in new window

0
 

Author Comment

by:jackjohnson44
ID: 36575927
Thanks, I can implement the first example, but when I try the second, the control doesn't load.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 36575944
I made a typo, it's Import, not Imports.

http://msdn.microsoft.com/en-us/library/eb44kack.aspx
0
 

Author Comment

by:jackjohnson44
ID: 36576673
Thanks, I am having issues and I am not sure what is wrong.  I had this working using the full name, then tried the other and now nothing will work.

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?)

Again, I believe that I had this working.  I am not sure why this is happening.

Thanks again for your help.
0
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 36578365
in your aspx on the top type <%@ Import Namespace="Fmg.Cti.UI.Utilities.Classes.ResourceController" %> or whatever the namespace your classes are in

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp web application 3 39
c# DateTime Format validation 4 68
Access is denied error from google drive api v2 in asp.net 1 45
global Variable - 2 functions in powershell 1 20
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question