L
lisa
I have a weird thing going on. I think I've figured out what's causing
my problem, but I can't find any way to fix it.
I have a custom server control that wraps a <select> in a <div> in
order to emulate a WinForms listbox. It works nicely.
I have another custom server control that includes two of the custom
listboxes and some buttons and is a Dual/Double/Swap/Pick list. You've
all seen the sort of thing I mean. It works nicely also.
Here's my problem. For the custom ListBox to work, it has to emit
three lines of startup script, one of which calls a function that
resizes the <select> within the <div>. That works fine as well.
My problem comes when I databind the two internal ListBoxes inside of
my PickList. Databinding them causes <option>s to be added to the
<select>s. But the startup script fires before the databinding, when
the <select>s are empty. So it doesn't work properly.
The thing is, I'm not always going to be databinding. I can add
records manually as well (PickList.SourceItems.Add(...), for instance).
I don't want to fire the startup script for each item that gets bound
into the listbox(es). Just once per listbox, when the page is fully
loaded into the browser. That shouldn't be a problem, should it?
But it seems that the ListBoxes emit the javascript as soon as they're
loaded into the PickList. Before databinding (or adding).
I don't want to force the users to have to put an onload event onto
their <body> tags, or add runat=server to the <body> tags either. I'd
like this to be a simple, usable component.
Ultimately, if I absolutely have to, I can be object disoriented and
copy the code for the custom listboxes into the picklist. But OOP
isn't supposed to be like that.
Can anyone here make a suggestion as to how I can get the startup
script to run only after the page is finished loading in the browser?
my problem, but I can't find any way to fix it.
I have a custom server control that wraps a <select> in a <div> in
order to emulate a WinForms listbox. It works nicely.
I have another custom server control that includes two of the custom
listboxes and some buttons and is a Dual/Double/Swap/Pick list. You've
all seen the sort of thing I mean. It works nicely also.
Here's my problem. For the custom ListBox to work, it has to emit
three lines of startup script, one of which calls a function that
resizes the <select> within the <div>. That works fine as well.
My problem comes when I databind the two internal ListBoxes inside of
my PickList. Databinding them causes <option>s to be added to the
<select>s. But the startup script fires before the databinding, when
the <select>s are empty. So it doesn't work properly.
The thing is, I'm not always going to be databinding. I can add
records manually as well (PickList.SourceItems.Add(...), for instance).
I don't want to fire the startup script for each item that gets bound
into the listbox(es). Just once per listbox, when the page is fully
loaded into the browser. That shouldn't be a problem, should it?
But it seems that the ListBoxes emit the javascript as soon as they're
loaded into the PickList. Before databinding (or adding).
I don't want to force the users to have to put an onload event onto
their <body> tags, or add runat=server to the <body> tags either. I'd
like this to be a simple, usable component.
Ultimately, if I absolutely have to, I can be object disoriented and
copy the code for the custom listboxes into the picklist. But OOP
isn't supposed to be like that.
Can anyone here make a suggestion as to how I can get the startup
script to run only after the page is finished loading in the browser?