?
Solved

Problem passing array(list) to custom server control

Posted on 2007-11-20
5
Medium Priority
?
235 Views
Last Modified: 2008-02-01
I tried making a full custom server control and somehow after giving it values through the aspx web app, the array is null.
Private mStoreArray As Array
 
    Public Property StoreArray() As Array
        Get
            Return mStoreArray
        End Get
        Set(ByVal value As Array)
            mStoreArray = value
        End Set
    End Property
 
Dim i As Short
        For i = 0 To StoreArray.Length - 1
            output.RenderBeginTag(HtmlTextWriterTag.Tr)
            output.RenderBeginTag(HtmlTextWriterTag.Td)
            output.Write(StoreArray(i))
            output.RenderEndTag()
            output.RenderEndTag()
        Next

Open in new window

0
Comment
Question by:Sharalynn
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:john_steed
ID: 20322412
Hi,

I'm assuming the code below is contained in a render function
       For i = 0 To StoreArray.Length - 1
            output.RenderBeginTag(HtmlTextWriterTag.Tr)
            output.RenderBeginTag(HtmlTextWriterTag.Td)
            output.Write(StoreArray(i))
            output.RenderEndTag()
            output.RenderEndTag()
        Next

So you need to make sure you've filled the array BEFORE this executes, also after a postback the array is empty, so you need to fill it again or store it in the viewstate

hope this helps
0
 

Author Comment

by:Sharalynn
ID: 20325234
Hi,

Yes that code is contained in the RenderContents method, and I have previously tried to populate the array on Page_Load in my testWebsite. The objArray.Length executed here indeed returns  So what is wrong here?
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   Dim dataList As String
        Dim MCListBox As New MCListBox.MCListBox
        Dim objArray As Array
        dataList = "1;Storage;2;Database;3;" & _
        "Security;4;JavaScript;5;Web Programming;6;" & _
        "Networking"
        objArray = dataList.Split(";")
        PagedListBox.StoreArray = objArray
End Sub

Open in new window

0
 
LVL 3

Expert Comment

by:john_steed
ID: 20326023
Hi,

Try putting a breakpoint on where you fill the array and where you use it to populate the control. If the control renders first, fill it in Page_Init instead

Hope this helps

Cheers
0
 

Author Comment

by:Sharalynn
ID: 20326909
Hi, I've checked and the flow is accordingly to the way it is supposed to be at least for the Page_Load, but after that all goes bonkers.
0
 
LVL 3

Accepted Solution

by:
john_steed earned 1500 total points
ID: 20330148
Still no luck ?

when you place a breakpoint on where you fill the property StoreArray()
and one where you loop through it, you can see if the property get filled before you loop through it. If this is the case it should function properly.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Integration Management Part 2
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question