In a user control I have an unordered list that contains items showing editable file data.
I create these items in my javascript using a JSON string set in a hidden field when the page is loaded or when the controlling element (AJAX async file upload) performs it’s OnClient_UploadComplete function.
Everything I have is solid so far: the items are created on the client side, and I can get any values changed using an existing hidden field and transfer the data back to a BL object when I need it.
My problem is that during the server-side On_UploadComplete function, my server code cannot find any of the dinamically created items created by my javascript to add essential data to the new item.
I have to be missing something. The value I get from the control is "/r/n"..
My best guess is that my c# code is set up wrong. On the page, to find the ul I have:
Control m_ulFileItems = m_fuPhotoUpload.FindControl("m_ulFileItems");
I’ll do some more loking, but this is an important aspect of getting this control to work.
I do not have any idea how you could be able to access these controls on server side. However, what I would suggest is that you pass their values from client to server, perhaps like this:
$.ajax({
url: …,
type: …,
data: ids and values from your controls in json format
});
Here are some more details:
if this is the HTML:
And I have added some text boxes the following way:
Then this should work:
Hope it helps.
If you do not like the Ajax call to the server I can suggest to use a hidden control, and put that string into the hidden control before you go to the server. Then you will be able to take the value of that hidden control on the server side.
Anyway, this is the basic idea – collect and prepare the data on the client side, then send it to the server side somehow.