G
gonzal kamikadze
Hi
It is possible to access a placeHolder in a aspx page from a class (compiled
code)?
(coding in VB)
--- ASPX page ---
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
debug="true" %>
<%@ Import Namespace="myNameSpace" %>
<script runat="server">
Sub page_Load()
Dim myClass As New testClass
myClass.testSub
End Sub
</script>
<html>
<title>test page</title>
<body>
<form ID="form1" runat="server">
<asplaceHolder ID="plhTest" runat=server" />
</form>
</body>
</html>
--- page.vb ---
Imports system
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Namespace myNameSpace
Public Class testClass
Inherits Page
Public plhTest as PlaceHolder
Sub testSub()
Dim myLabel As New Label
myLabel.Text = " - TEST LABEL - "
plhTest.Controls.Add(myLabel)
End Sub
End Class
End Namespace
I'm getting all the time an error message like this:
System.NullReferenceException: Object reference not set to an instance of an
object.
does anybody know the solution to the above problem??? thanks
regards
It is possible to access a placeHolder in a aspx page from a class (compiled
code)?
(coding in VB)
--- ASPX page ---
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
debug="true" %>
<%@ Import Namespace="myNameSpace" %>
<script runat="server">
Sub page_Load()
Dim myClass As New testClass
myClass.testSub
End Sub
</script>
<html>
<title>test page</title>
<body>
<form ID="form1" runat="server">
<asplaceHolder ID="plhTest" runat=server" />
</form>
</body>
</html>
--- page.vb ---
Imports system
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Namespace myNameSpace
Public Class testClass
Inherits Page
Public plhTest as PlaceHolder
Sub testSub()
Dim myLabel As New Label
myLabel.Text = " - TEST LABEL - "
plhTest.Controls.Add(myLabel)
End Sub
End Class
End Namespace
I'm getting all the time an error message like this:
System.NullReferenceException: Object reference not set to an instance of an
object.
does anybody know the solution to the above problem??? thanks
regards