By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,969 Members | 2,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,969 IT Pros & Developers. It's quick & easy.

import of dynamic class file

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.