Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem passing array(list) to custom server control

Posted on 2007-11-20
5
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

636 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