G
Guest
Hi,
I guess I am confused. In aspx script, I mean (you won't use
Codebehind="enrollinfo.aspx.vb", but mix code with html and code together)
You can access user control's property directly. Since I am useing visual
studio .net,
the html and code are seperated.
I have the following aspx code which has two user controls:
<%@ Register TagPrefix="Subway" TagName="Peopleinfo" Src="Peopleinfo.ascx" %>
<%@ Register TagPrefix="Subway" TagName="Address" Src="Address.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="enrollinfo.aspx.vb" Inherits="subway.enrollinfo"%>
....
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<SUBWAY:ADDRESS id="address" runat="server" Caption="Home
Address"></SUBWAY:ADDRESS>
<p></p>
<SUBWAY
EOPLEINFO id="Peopleinfo" runat="server" Caption="Employee
Information"></SUBWAY
EOPLEINFO>
<p></p>
<asp:hyperlink id="Dependentlink" runat="server"
NavigateUrl="Peopleinfo1.aspx?SSN=" text="Add Dependents for
"></asp:hyperlink>
<asp:Button id="Button1" runat="server" Text="Add Dependents"></asp:Button>
</form>
</body>
</HTML>
and in enrollinfo.aspx.vb
I didn't see user controls' declaration in enrollinfo.aspx.vb, only two
server controls appear:
Protected WithEvents Dependentlink As System.Web.UI.WebControls.HyperLink
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
so I added "Public People As PeopleInfo" myself, and later on,
and I have the following:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
People = New PeopleInfo
If People.SSN <> "" Then
Response.Redirect("Peopleinfo1.aspx?SSN" + People.SSN.ToString)
End If
End Sub
Peopleinfo is user control class and I tried to access its SSN property ,
but it gives
me error message something like: Null reference object accessed.
It seems that People.SSN is a wrong way, can you give me a hint? I have
properties for peopleinfo control already, here it is:
Public Class PeopleInfo
Inherits System.Web.UI.UserControl
Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox
Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtSSN As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtPlan As System.Web.UI.WebControls.TextBox
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private designerPlaceholderDeclaration As System.Object
Public Caption As String = "Dependent Information"
Private _ShowCaption As Boolean = True
Public Property ShowCaption() As Boolean
Get
Return _ShowCaption
End Get
Set(ByVal Value As Boolean)
_ShowCaption = value
End Set
End Property
Public Property FirstName() As String
Get
Return txtFirstName.Text
End Get
Set(ByVal Value As String)
txtFirstName.Text = Value
End Set
End Property
Public Property LastName() As String
Get
Return txtLastName.Text
End Get
Set(ByVal Value As String)
txtLastName.Text = Value
End Set
End Property
Public Property SSN() As String
Get
Return TxtSSN.Text
End Get
Set(ByVal Value As String)
TxtSSN.Text = Value
End Set
End Property
Public Property Plan() As String
Get
Return TxtPlan.Text
End Get
Set(ByVal Value As String)
TxtPlan.Text = Value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
Betty
I guess I am confused. In aspx script, I mean (you won't use
Codebehind="enrollinfo.aspx.vb", but mix code with html and code together)
You can access user control's property directly. Since I am useing visual
studio .net,
the html and code are seperated.
I have the following aspx code which has two user controls:
<%@ Register TagPrefix="Subway" TagName="Peopleinfo" Src="Peopleinfo.ascx" %>
<%@ Register TagPrefix="Subway" TagName="Address" Src="Address.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="enrollinfo.aspx.vb" Inherits="subway.enrollinfo"%>
....
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<SUBWAY:ADDRESS id="address" runat="server" Caption="Home
Address"></SUBWAY:ADDRESS>
<p></p>
<SUBWAY
Information"></SUBWAY
<p></p>
<asp:hyperlink id="Dependentlink" runat="server"
NavigateUrl="Peopleinfo1.aspx?SSN=" text="Add Dependents for
"></asp:hyperlink>
<asp:Button id="Button1" runat="server" Text="Add Dependents"></asp:Button>
</form>
</body>
</HTML>
and in enrollinfo.aspx.vb
I didn't see user controls' declaration in enrollinfo.aspx.vb, only two
server controls appear:
Protected WithEvents Dependentlink As System.Web.UI.WebControls.HyperLink
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
so I added "Public People As PeopleInfo" myself, and later on,
and I have the following:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
People = New PeopleInfo
If People.SSN <> "" Then
Response.Redirect("Peopleinfo1.aspx?SSN" + People.SSN.ToString)
End If
End Sub
Peopleinfo is user control class and I tried to access its SSN property ,
but it gives
me error message something like: Null reference object accessed.
It seems that People.SSN is a wrong way, can you give me a hint? I have
properties for peopleinfo control already, here it is:
Public Class PeopleInfo
Inherits System.Web.UI.UserControl
Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox
Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtSSN As System.Web.UI.WebControls.TextBox
Protected WithEvents TxtPlan As System.Web.UI.WebControls.TextBox
Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private designerPlaceholderDeclaration As System.Object
Public Caption As String = "Dependent Information"
Private _ShowCaption As Boolean = True
Public Property ShowCaption() As Boolean
Get
Return _ShowCaption
End Get
Set(ByVal Value As Boolean)
_ShowCaption = value
End Set
End Property
Public Property FirstName() As String
Get
Return txtFirstName.Text
End Get
Set(ByVal Value As String)
txtFirstName.Text = Value
End Set
End Property
Public Property LastName() As String
Get
Return txtLastName.Text
End Get
Set(ByVal Value As String)
txtLastName.Text = Value
End Set
End Property
Public Property SSN() As String
Get
Return TxtSSN.Text
End Get
Set(ByVal Value As String)
TxtSSN.Text = Value
End Set
End Property
Public Property Plan() As String
Get
Return TxtPlan.Text
End Get
Set(ByVal Value As String)
TxtPlan.Text = Value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
Betty