JavaScript的创建的控制值不会发布到服务器 [英] javascript created control values are not posting to server

查看:107
本文介绍了JavaScript的创建的控制值不会发布到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的HTML页面中我用JavaScript循环创建一些文本框。

In my Html page I create a few textboxes in a loop with javascript.

从内环路code片断:

code snippet from inside loop:

var row = myTable.tBodies[0].insertRow(rowCount);
var cell1 = row.insertCell(0);
cell1.style.width = '40%';
var element1 = document.createElement("input");
element1.type = "text";
element1.className = 'textSub';
element1.id = 'txtOndNr' + rowNr;
cell1.appendChild(element1); 

当我preSS提交按钮,我似乎无法存取权限它们的值服务器端。我知道自己不是服务器控件等,但我希望通过到的Request.Form他们存取权限(ID)。
此外,当我检查萤火虫,这些值没有在后值(控制位于表单标签里面,这不是问题)。

When I press the submit button I can't seem to acces their values server side. I am aware that they are not server controls etc. But I hoped to acces them through request.form("id"). Also when I check firebug, these values are not in the post values (the controls are located inside the form tags, that's not the issue).

有没有人有一个想法是什么,我做错了?

Does anyone have an idea of what I'm doing wrong?

额外的信息:ASP.NET 1.1,脚本位于ASCX

Extra info: ASP.NET 1.1, script is located in ASCX

推荐答案

我刚刚发现它不是用来发送表单值,但名称中的ID。如果我改变 element1.id ='txtOndNr'+ rowNr; element1.name ='txtOndNr'+ rowNr; 我可以REQUEST.FORM(txtOndNr0)存取权限这些值。

I just found out that it's not the ID that is used to send form values but the NAME. If i change element1.id = 'txtOndNr' + rowNr; to element1.name = 'txtOndNr' + rowNr; I can acces these values with Request.form("txtOndNr0").

貌似这个检查时萤火HTTP POST请求

Looks like this when checking firebug http post request

txtOndNr0   qsdf
txtOndNr1   
txtOndNr2   qsdf

对我来说这看起来像一个稍微清晰的解决方案。

To me this looks like a slightly cleaner solution.

这篇关于JavaScript的创建的控制值不会发布到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆