I have a User Control called 'FileBrowser.' The control contains a ListBox called 'FileList.' The code behind exposes a property:
public string SelectedPath
{ get { return string.IsNullOrEmpty(FileList.SelectedValue) ? "empty" : FileList.SelectedValue; } }
I am accessing this from a page implementing the control using this:
<script>
function testFunc() {
var s = '<% Response.Write(fileBrowser.SelectedPath);%>';
document.getElementById('<%= textBoxTest.ClientID %>').value = s;
}
</script>
I see some very strange behavior. When I click the button textBoxTest I get the value of SelectedValue from when the button was last clicked.
Example:
FileList.SelectedPath = Test1
click returns "empty"
click again, now it returns "Test1"
Select a new value on the listbox, test2, click again, returns "Test1"
Click again, returns "test2"
I'm very new to ASP.NET and web development in general. I suppose maybe there are some strange life cycle events occuring that I am not familiar with.