473,378 Members | 1,393 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,378 software developers and data experts.

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.ClientID
Dim ScriptString as String = "<script
language='javascript'>document.getElementById('" & ClientID &
"').focus();</script>"
RegisterStartupScript("setFocus", 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="CommonFunctions" %>

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 1772
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='javascript'>document.getElementById('" & controlClientId &
"').focus();</script>"
ctype(HttpContext.Current.Handler,
Page).RegisterStartupScript("setFocus", ScriptString)
End Sub
End Class
notice three things:
1 - I made the function shared...which means you can access it via
Functions.SetFocus(
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.Current.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********@officedepot.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.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.ClientID
Dim ScriptString as String = "<script
language='javascript'>document.getElementById('" & ClientID &
"').focus();</script>"
RegisterStartupScript("setFocus", 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="CommonFunctions" %>

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
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...
0
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...
1
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...
3
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
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...
110
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...
3
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...
10
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.