A
ayende
I got the following JS function:
<script language="javascript" type="text/javascript">
function addUser()
{
var users = document.getElementById('users');
var hidden = document.createElement('input');
hidden.value = 'foo';
users.appendChild(hidden);
var i =0;
for(var node = users.firstChild;node !=null; node =
node.nextSibling)
{
if(node.nodeType != 1) //input
continue;
node.id = 'project.Users['+i+'].Id';
i++;
}
}
</script>
And the following form:
<form id="form1" runat="server">
<div id="users">
<input id="Button1" type="button" value="Add User"
onclick="javascript:addUser();" />
</div>
<asp:TextBox ID="PostBackValues" runat="server" Height="225px"
TextMode="MultiLine" Width="596px"></asp:TextBox><br />
<asp:Button ID="submit" runat="server" Text="submit"
OnClick="submit_Click" /><br />
</form>
I open the page, click on the Add User button a couple of times, and
then submit.
In my code behind file I have:
protected void submit_Click(object sender, EventArgs e)
{
foreach (string key in Request.Params.AllKeys)
{
PostBackValues.Text += string.Format(" {0}: {1}\r\n", key,
Request.Params[key]);
}
}
But I can't see the values I set using JS. In fact, when checking with
Fiddler, I can see that they aren't added to the POST varaibles at all.
Any ideas what this is?
<script language="javascript" type="text/javascript">
function addUser()
{
var users = document.getElementById('users');
var hidden = document.createElement('input');
hidden.value = 'foo';
users.appendChild(hidden);
var i =0;
for(var node = users.firstChild;node !=null; node =
node.nextSibling)
{
if(node.nodeType != 1) //input
continue;
node.id = 'project.Users['+i+'].Id';
i++;
}
}
</script>
And the following form:
<form id="form1" runat="server">
<div id="users">
<input id="Button1" type="button" value="Add User"
onclick="javascript:addUser();" />
</div>
<asp:TextBox ID="PostBackValues" runat="server" Height="225px"
TextMode="MultiLine" Width="596px"></asp:TextBox><br />
<asp:Button ID="submit" runat="server" Text="submit"
OnClick="submit_Click" /><br />
</form>
I open the page, click on the Add User button a couple of times, and
then submit.
In my code behind file I have:
protected void submit_Click(object sender, EventArgs e)
{
foreach (string key in Request.Params.AllKeys)
{
PostBackValues.Text += string.Format(" {0}: {1}\r\n", key,
Request.Params[key]);
}
}
But I can't see the values I set using JS. In fact, when checking with
Fiddler, I can see that they aren't added to the POST varaibles at all.
Any ideas what this is?