Dynamically generated controls (Javascript) not posting values to server

A

ayende

I've a very strange issue here. I've this JS code:

var hidden = document.createElement('input')
//hidden.type='hidden';
hidden.value = getIdForUser(userTag)
$('assignedUsersInputs').appendChild(hidden);
var i =0;
for(var node = $('assignedUsersInputs').firstChild;node !=null; node =
node.nextSibling)
{
if(node.nodeType != 1) //input
continue;
node.id = 'project.Users['+i+'].Id';
i++;
}

I use it to create a couple of inputs, and then I post to the server,
but the server side can't see those controls.
When I do request.Params.AllKeys, I can't see those values there, but
they exists (enabled, btw) on the client.
This behavior is consistent in both IE and FF, so I think this is
something that I'm doing wrong.
Any ideas?
 
K

Ken Cox - Microsoft MVP

Unless you create the hidden control as an ASP.NET control, I don't think
ASP.NET is going to "see" your control.

The server-side code used by ASP.NET needs to be told about anything
generated on the client-side, especially if it is dynamic.

Try creating two ASP.NET server-side hidden controls and storing whatever
values you get from the dynamic inputs in those?

Let us know?

Ken
Microsoft MVP [ASP.NET]
 
A

ayende

I'm not trying to make ASP.Net see them, I'm trying to extract those
values manually.
The problem is, as far as I can see, they are not sent to the server
from the browser
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top