Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net call code inline

Posted on 2011-09-21
5
Medium Priority
?
463 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 Ageil earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2

927 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