How do I reference objects in App_Code?

curiouswebster
curiouswebster used Ask the Experts™
on
I have two objects defined in two files, each sharing the same namespace. I have configured their properties to each specify the Build Action as Compile.  

How do I reference the objects or the namespace from the .aspx file?  I have a question about the format.

Thanks,
newbieweb
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
on the top of your page
<%........ Inherits="mycustomname.myclass" %>
curiouswebsterSoftware Engineer

Author

Commented:
how do I interpret "........." ???

Commented:
"..." is ehat ever else you have
in <%@ Register on top
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

curiouswebsterSoftware Engineer

Author

Commented:
Now I am confused.

Please give me a sample complete line instead of this:
<%........ Inherits="mycustomname.myclass" %>

I have one namespace and two object in that namespace. I am not looking for an education in all the things I could do, I really need to get past this roadblock and need the exact syntax.

Thanks,
newbieweb
Vikram Singh SainiSoftware Engineer cum AD Developer
Commented:
Hi newbieweb,

Check link:
http://niitdeveloper.blogspot.com/2010/10/how-to-use-appcode-classes-in-aspx-and.html

Let us know if problem still persists.

Regards,
VSS
curiouswebsterSoftware Engineer

Author

Commented:
I think that's working.  But where do I define a variable I will want to use in various functions on the page?
Vikram Singh SainiSoftware Engineer cum AD Developer
Commented:
Hi,

You can declare between <script type="text/C#" runat="server"></script> and use as you wants. Check code snippet.

Regards,
VSS

<script type="text/C#" runat="server">
        string var2,var3;  //Declare here
        protected void btnTest_Click(object sender, EventArgs e)
        {
            File1 file = new File1();
            string var = file.ShowName();
            var2 = var;
            Response.Write(var2);
        }
    </script>

Open in new window

curiouswebsterSoftware Engineer

Author

Commented:
Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial