473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to reference module function from inline script in ASPX?

I have a ASP.NET web app with a common module. How can I access the Public functions in the common module from the 'in-line' scripts in the ASPX page?

...from the ASPX page...

<asp:Label runat="server"
BackColor='<%# System.Drawing.ColorTranslator.FromHTML(Module1.Wa rnLOS(Module1.LOSMinutes(DataBinder.Eval(Container .DataItem,"vAdmDtTm"))))%>'
Text='<%# DataBinder.Eval(Container, "DataItem.rmDesc")%>'
ID="Label2">
</asp:Label>
The Public functions in the common module (WarnLOS and LOSMinutes) do some conversions, but I reuse these function in a lot of the pages - so I wanted to put them in one place - the common module.

THE PROBLEM: I get this error:
Compiler Error Message: BC30451: Name 'Module1' is not declared.
When I try to access the functions from the common module. How do I declare Module1 from the in-line scripts?

--------------------------------
From: kevin buchanan

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>fmKso6cO406+yl6+DmYXSw==</Id>
Nov 19 '05 #1
1 2157
You can use this directive at the top of your ASPX page
<%@ Import namespace="CommonModileNamespace" %>

to access the Module1 without any namespace qualifier at the start of the
class definition. Otherwise, you can still access the common functions
(provided the DLL they reside in is in the /bin directory) but you must
fully quialify the class declaration such as:

RootNameSpace.YourProjectNamespace.Module1 obj = new
RootNameSpace.YourProjectNamespace.Module1();
obj.WarnLOS();

when you use the Import directive you can do

Module1 obj = new Module1();
obj.WarnLOS();
--

- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"kevin buchanan via .NET 247" <an*******@dotnet247.com> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
I have a ASP.NET web app with a common module. How can I access the Public functions in the common module from the 'in-line' scripts in the ASPX
page?
..from the ASPX page...

<asp:Label runat="server"
BackColor='<%# System.Drawing.ColorTranslator.FromHTML(Module1.Wa rnLOS(Module1.LOSMinutes(D
ataBinder.Eval(Container.DataItem,"vAdmDtTm"))))%> ' Text='<%# DataBinder.Eval(Container, "DataItem.rmDesc")%>'
ID="Label2">
</asp:Label>
The Public functions in the common module (WarnLOS and LOSMinutes) do some conversions, but I reuse these function in a lot of the pages - so I wanted
to put them in one place - the common module.
THE PROBLEM: I get this error:
Compiler Error Message: BC30451: Name 'Module1' is not declared.
When I try to access the functions from the common module. How do I declare Module1 from the in-line scripts?
--------------------------------
From: kevin buchanan

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>fmKso6cO406+yl6+DmYXSw==</Id>

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jon Maz | last post by:
Hi All, I've just noticed that there seem to be two ways of setting up a global.asax file. At http://www.csharphelp.com/archives/archive206.html the global.asax example has Application_Start...
8
by: Sreenivas | last post by:
Hi, We cannot return a reference to an automatic variable from a function, as per the ANSI C++ standard the behaviour is undefined. Does this hold for inline functions too? or can I return a...
2
by: Fred Armitage | last post by:
I have a fairly complex application written using a vb code-behind dll. However, I'd like to write one particular aspx page utilising in-line code so that it can easily be modified as needed by the...
5
by: Greg Collins [MVP] | last post by:
I have an ASP.NET page that uses a tag: <asp:Xml id="foo" runat="server" DocumentSource="rss.xml" TransformSource="rss20.xsl" /> This creates a Web page from an XML file that was generated by...
11
by: Pdarroch | last post by:
Hello All I am trying to upgrade my existing website from ASP to ASP.NET and I have a file which included various functions common to several pages in the site. While trying to convert this page...
8
by: neilmcguigan | last post by:
I just wanted to list some reasons why I prefer inline code to code-behind. 1. you can fix some bugs more quickly. remote desktop into server, change the aspx file, and she's good to go. I'd say...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
4
by: shustes | last post by:
Hi, I need to access XML data from a Sharepoint 2003 default.aspx page. There is no Visual Studio project and no code behind, yet I need to employ the System.XML namespace. Any assistence and...
3
by: Kermit Mei | last post by:
Hello all, I wrote four simple c++ source files for this test. Look please: /*************1***************/ /// file A.h #ifndef A_H #define A_H class A { public: void set(int i);
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.