Solved

Problem passing array(list) to custom server control

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now