471,085 Members | 1,071 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

import of dynamic class file

Hello?

On the ASP.NET, I can use the class by import declation on the top of page.

<%@ page language="vb" explicit="true" aspcompat="false" debug="true"%>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>

It's work well for the compiled class files in /bin folder.

But, I have a problem on using class file which are not complied.
How can I import or include it to asp.net source code?

For example. I have two class files written in vb.net.

student.aspx.vb
<script language="vb" runat="server">
public class Student
....
end class
</script>

teacher.aspx.vb
<script language="vb" runat="server">
public class Teacher
....
end class
</script>

If I try to include both class file to asp.net code.

<!-- #include file="student.aspx.vb" -->
<!-- #include file="teacher.aspx.vb" -->

It occur error that the definition of class was not founded on running.
If I merge the classfile to one file. then, It work well.
Is there are any method to use indivisual files on asp.net?

Hope for your kindly reply.

Thanks!

Nov 18 '05 #1
2 3244
Hello,

You can use the @ Reference Directive in ASP.Net.
From the German .Net Framework Documentation:

<%@ Reference page | control="pathtofile" %>

Attribute
Page
Die Web Forms-Seite, die von ASP.NET zur Laufzeit dynamisch
kompiliert und mit der aktuellen Seite verknüpft werden soll.
Control
Das Benutzersteuerelement, das von ASP.NET zur Laufzeit dynamisch
kompiliert und mit der aktuellen Seite verknüpft werden soll.
C#]
<%@ Reference Control="MyControl.ascx" %>
<script language="C#" runat=server>

void Page_Load(Object sender, EventArgs e) {

// In the @ Control directive in the MyControl.ascx file,
// you must include classname="MyControl" for this to work.
MyControl myControl = (MyControl)
Page.LoadControl("MyControl.ascx");
myControl.MyProperty = "Color";

PlaceHolder.Controls.Add(myControl);
}

</script>

<html>
<body>
<asp:placeholder id="PlaceHolder" runat=server/>
</body>
</html>
Hope this helps!
schorsch

On Thu, 3 Jun 2004 19:11:26 +0900, "s.hong" <s.****@spamxxx.com>
wrote:
Hello?

On the ASP.NET, I can use the class by import declation on the top of page.

<%@ page language="vb" explicit="true" aspcompat="false" debug="true"%>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>

It's work well for the compiled class files in /bin folder.

But, I have a problem on using class file which are not complied.
How can I import or include it to asp.net source code?

For example. I have two class files written in vb.net.

student.aspx.vb
<script language="vb" runat="server">
public class Student
....
end class
</script>

teacher.aspx.vb
<script language="vb" runat="server">
public class Teacher
....
end class
</script>

If I try to include both class file to asp.net code.

<!-- #include file="student.aspx.vb" -->
<!-- #include file="teacher.aspx.vb" -->

It occur error that the definition of class was not founded on running.
If I merge the classfile to one file. then, It work well.
Is there are any method to use indivisual files on asp.net?

Hope for your kindly reply.

Thanks!


Nov 18 '05 #2
Thanks Karl,

I succeed to use the class files on my asp.net page.
But, It's needed to generate ascx files for each class file to use
@Reference derective.

Thank you very much!

"Karl Bauer" <sc********@yahoo.de> wrote in message
news:0b********************************@4ax.com...
Hello,

You can use the @ Reference Directive in ASP.Net.
From the German .Net Framework Documentation:

<%@ Reference page | control="pathtofile" %>

Attribute
Page
Die Web Forms-Seite, die von ASP.NET zur Laufzeit dynamisch
kompiliert und mit der aktuellen Seite verknüpft werden soll.
Control
Das Benutzersteuerelement, das von ASP.NET zur Laufzeit dynamisch
kompiliert und mit der aktuellen Seite verknüpft werden soll.
C#]
<%@ Reference Control="MyControl.ascx" %>
<script language="C#" runat=server>

void Page_Load(Object sender, EventArgs e) {

// In the @ Control directive in the MyControl.ascx file,
// you must include classname="MyControl" for this to work.
MyControl myControl = (MyControl)
Page.LoadControl("MyControl.ascx");
myControl.MyProperty = "Color";

PlaceHolder.Controls.Add(myControl);
}

</script>

<html>
<body>
<asp:placeholder id="PlaceHolder" runat=server/>
</body>
</html>
Hope this helps!
schorsch

On Thu, 3 Jun 2004 19:11:26 +0900, "s.hong" <s.****@spamxxx.com>
wrote:
Hello?

On the ASP.NET, I can use the class by import declation on the top of page.
<%@ page language="vb" explicit="true" aspcompat="false" debug="true"%>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>

It's work well for the compiled class files in /bin folder.

But, I have a problem on using class file which are not complied.
How can I import or include it to asp.net source code?

For example. I have two class files written in vb.net.

student.aspx.vb
<script language="vb" runat="server">
public class Student
....
end class
</script>

teacher.aspx.vb
<script language="vb" runat="server">
public class Teacher
....
end class
</script>

If I try to include both class file to asp.net code.

<!-- #include file="student.aspx.vb" -->
<!-- #include file="teacher.aspx.vb" -->

It occur error that the definition of class was not founded on running.
If I merge the classfile to one file. then, It work well.
Is there are any method to use indivisual files on asp.net?

Hope for your kindly reply.

Thanks!


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by bry | last post: by
16 posts views Thread by didier.doussaud | last post: by
7 posts views Thread by Mike Livenspargar | last post: by
49 posts views Thread by Martin Unsal | last post: by
7 posts views Thread by bambam | last post: by

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.