Sharalynn
asked on
Problem passing array(list) to custom server control
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
ASKER
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?
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
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
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
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm assuming the code below is contained in a render function
For i = 0 To StoreArray.Length - 1
output.RenderBeginTag(Html
output.RenderBeginTag(Html
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