Solved

Problem passing array(list) to custom server control

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 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