|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
asp2.0 using public propertyI’m using ASP 2.0. I’m trying to use it in a public property routine to count for my array. It keeps coming back with a 0 value instead of incrementing. Code sample from mainscreen.aspx Partial Class mainscreen Inherits System.Web.UI.Page Dim clscmp As New clsCmpSetup Dim arrStatement(10, 1) Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim i As Integer Dim bisTrue As Boolean = False If Not bisTrue Then ddlStatements.Items.Add(txtTitle.Text) arrStatement(clscmp.ArrCnt, 0) = txtTitle.Text arrStatement(clscmp.ArrCnt, 1) = txtStatements.Text clscmp.ArrCnt = 1 End If END SUB Code sample from clsCmpSetup: Imports Microsoft.VisualBasic Public Class clsCmpSetup Dim _arrCnt As Integer Public Property ArrCnt() As Integer Get Return _arrCnt End Get Set(ByVal value As Integer) If value < 0 Then _arrCnt = 0 Else _arrCnt = _arrCnt + 1 End If End Set End Property End Class Your clscmp varibale is being initialized every time the page is being
loaded, so _arrCnt is always 0. Depending on what it is you're trying to achieve, look into storing either the clscmp object variable or the _arrCnt variable in ViewState or Session state. -- Show quoteCarsten Thomsen Senior .NET Solutions Architect / Developer / Author MCAD/MCSD/MCSE/MCTS "Logger" <Log***@discussions.microsoft.com> wrote in message news:AEFF81E9-AF3E-46D7-B932-B2E42E5A03B8@microsoft.com... > Can someone tell me why my integer variable _arrCnt is not holding its > value. > I'm using ASP 2.0. I'm trying to use it in a public property routine to > count for my array. It keeps coming back with a 0 value instead of > incrementing. > > Code sample from mainscreen.aspx > > Partial Class mainscreen > Inherits System.Web.UI.Page > Dim clscmp As New clsCmpSetup > Dim arrStatement(10, 1) > > > Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As > System.EventArgs) Handles btnSave.Click > Dim i As Integer > Dim bisTrue As Boolean = False > If Not bisTrue Then > ddlStatements.Items.Add(txtTitle.Text) > arrStatement(clscmp.ArrCnt, 0) = txtTitle.Text > arrStatement(clscmp.ArrCnt, 1) = txtStatements.Text > clscmp.ArrCnt = 1 > End If > > END SUB > > Code sample from clsCmpSetup: > > Imports Microsoft.VisualBasic > > Public Class clsCmpSetup > Dim _arrCnt As Integer > > Public Property ArrCnt() As Integer > Get > Return _arrCnt > End Get > Set(ByVal value As Integer) > If value < 0 Then > _arrCnt = 0 > Else > _arrCnt = _arrCnt + 1 > End If > > End Set > End Property > End Class > |
|||||||||||||||||||||||