473,795 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing functions in dlls from code behind

I have been researching this over the last two days without success.

I have a number of ultility functions that I want to make available to
all pages. The pages will all be using code behind so my plan is to
create an assembly CommonFunctions .dll place it in the /bin folder for
the application and import the namespace into the code behind where
required.

Here is an abstract of CommonFunctions .vb

Option Strict Off
Imports System etc etc etc

Namespace CommonFunctions
Public Class Functions

Inherits Page
Public Sub SetFocus(ByVal FocusControl As Control)

Dim ClientID As String = FocusControl.Cl ientID
Dim ScriptString as String = "<script
language='javas cript'>document .getElementById ('" & ClientID &
"').focus() ;</script>"
RegisterStartup Script("setFocu s", ScriptString)

End Sub

End Class
End Namespace

This compiles correctly and I have no problem using the SetFocus
function from a aspx with no code behind using
<%@ import Namespace="Comm onFunctions" %>

My problem comes when trying to use SetFocus in code behind script.
Even though I import the namespace I get the error BC30451: Name
'SetFocus' is not declared.

Thanks in advance

Nov 19 '05 #1
2 1791
If this truly is a utility class, it really shouldn' tinheirt Page...

Public Class Functions
Public shared Sub SetFocus(ByVal controlClientId As string)
Dim ScriptString as String = "<script
language='javas cript'>document .getElementById ('" & controlClientId &
"').focus() ;</script>"
ctype(HttpConte xt.Current.Hand ler,
Page).RegisterS tartupScript("s etFocus", ScriptString)
End Sub
End Class
notice three things:
1 - I made the function shared...which means you can access it via
Functions.SetFo cus(
2 - I passed in a string instead of the control (all you are doing with the
control is getting the clientId, so why not just pass in the clientId??)
3 - Since I no longer inherit Page, I need to get the current page via
HttpContext.Cur rent.Handler alternatively, I could pass the page as a 2nd
paramter

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"shaun duke" <sh********@off icedepot.co.uk> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I have been researching this over the last two days without success.

I have a number of ultility functions that I want to make available to
all pages. The pages will all be using code behind so my plan is to
create an assembly CommonFunctions .dll place it in the /bin folder for
the application and import the namespace into the code behind where
required.

Here is an abstract of CommonFunctions .vb

Option Strict Off
Imports System etc etc etc

Namespace CommonFunctions
Public Class Functions

Inherits Page
Public Sub SetFocus(ByVal FocusControl As Control)

Dim ClientID As String = FocusControl.Cl ientID
Dim ScriptString as String = "<script
language='javas cript'>document .getElementById ('" & ClientID &
"').focus() ;</script>"
RegisterStartup Script("setFocu s", ScriptString)

End Sub

End Class
End Namespace

This compiles correctly and I have no problem using the SetFocus
function from a aspx with no code behind using
<%@ import Namespace="Comm onFunctions" %>

My problem comes when trying to use SetFocus in code behind script.
Even though I import the namespace I get the error BC30451: Name
'SetFocus' is not declared.

Thanks in advance

Nov 19 '05 #2
Karl,

Thanks for the reply, This works perfectly.

Cheers
Shaun

Nov 19 '05 #3

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

Similar topics

3
2039
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object handles are stored in session variables. This works fine without a problem. Ported it to ASPX, accessing the same DCOM server from code behind pages. Still, usually no problems. However sometimes I'm seeing an error stating that the DCOM handle...
0
3230
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs converted/developed with VB.NET. What I want from debugging is to be able to step into the methods in the DLLs called from ASP scripts using Visual Studio .NET. Background: For typical script debugging issues, you can read and follow the two documents on...
1
340
by: Arne | last post by:
All my code behind pages gets compiled into one DLL. I would like to redirect my code behind into multiple DLLs so that I get more flexibility when installing new features to a web site. I am adding some new features to a web sites that are not ready for production. At the same I would like to be able to fix bugs without installing the new features. I would like to put the new features into a separate DLL and keep all the old feature in another...
3
2437
by: John | last post by:
Hi What are the advantages of storing ones class project dlls in gac? How can one access these dlls? Thanks Regards
3
1343
by: Dave | last post by:
I've seen at least one article on this: How to access classes, etc. managed-to-unmanaged. I can't find it. Any tricks or pointers? I guess the class name won't get munged but I'm not clear about necessary class declarations.
110
8624
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm almost halfway through writing the over 200 functions needed to implement C99's version of math.h, and I would like to have some feedback and/or expert advice on my implementations. Sincerely, Gregory Pietsch
3
1929
by: =?Utf-8?B?WmlhbmdpIEpvbmVz?= | last post by:
Hi, I m using VS .NET 2003 to create a website. Using the setup package I create a setup as well. But this setup has files with actual code in it & not pre-compiled DLLs. Please let me know what needs to be done to ensure that DLLs are produced & not code files. Note: BOTH 'codebehind' & 'SRC' attribute has been used. --
10
1930
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I usually deploy my ASP .NET application to the server by publishing, using Visual Studio 2005 publish feature. This creates the Bin folder on the server, with the compiled DLLs. I've been asked to publish by copying the files manually instead. I stopped IIS for the application, deleted the application files and subfolders from the server, copied the files and folders from my local PC's project,
3
2037
by: Patrice | last post by:
Hi all, I'm currently upgrading a 1.1 application. We were using a command file to invoke the command line compiler to that we have the code behind compiled into multiple DLLs (to be able to deploy one "part" of the site while working on another, this is an intranet that contains related but somewhat independant "modules"). I first thought it was possible in 2.0 but it seems now that actually this is only true for ASPX files and that...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.