Hi Sandy,
What I don't understand about it is, for instance, he has
<%@ Import Namespace="ASPNet101" %>
<%@ Assembly src="LIB.vb" %>
Am I supposed to put that in the HTML page, or put the Imports in the
vb
code behind page instead . . . or both?
You just need to tell the compiler where the functions are located in the
page you are using the common functions.
If you place the class file in the bin directory than asp.net will automaticly
compile that class each time the application runs and make it available to
the whole app.
So <%@ Assembly src="LIB.vb" %> isn't striclty necessary unless you want
to reference code thats in a directory outside the bin.
<%@ Import Namespace="ASPNet101" %> is necessary cause it tells the compiler
where to look if you write a function name.
You are saying with that statement that you want to make the classes available
to you in that page.
If I can possibly impose on you further, could you peruse my code
again and see where I made a mistake? What is causing the "squiggly"
error?
The error is caused by and OO issue. Remember that asp.net is OO based so
it supports inheritance, encapsulation,etc.
When you say that a method is shared, like you do with SetFocus, you make
it so that the user of that function doesnt have to instantiate the class
to an object to use the function (again this is OO lingo which you got to
get familiar with). But RegisterStartupScript is not a shared function so
it needs to be coupled to an object.
If you remove the shared keyword from SetFocus than the error will be gone.
I know why you put the shared keyword there cause you want to call common
functions as if they were baked in the runtime and not create an object firs.
But I set you on the wrong foot with my first reply so abondon Scotts article
and try to grasp the asp101. I bet this is what you want.
So to sum it up : Write a class file (.vb) and put it in the bin directory.
Put your class in a namespace and make all its functions shared.
In the page that you want to use the functions use the import namespace directive.
Now you can use the functions like this :
classX.functionX
Let me know if you have any more questions.. but I suggest you read everything
you can about asp.net and its OO features cause I can't write good tutorials
Cheers,
Tom Pester