Solved

Problem passing array(list) to custom server control

Posted on 2007-11-20
5
202 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 500 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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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