English 中文(简体)
如何使用 HTTP 邮件在 ASPX 页面中提交部分或全部控件
原标题:How to submit some or All controls in an ASPX page using HTTP post

我有名为 ShowDestress.aspx 的 asspx 页面, 使用 URL myurl.com/showdesign.aspx? id= 420420 浏览 。

Aspx 页面有许多控件, 如图像、 文本按钮、 收音机按钮等 。 有些控件是在代码后面创建的, 大多数控件的值是在代码后面指定/ 更新的 。

当页面准备显示时, 我想在一些控件上使用 HTTP Post( 也可以使用 HTTP post 整个页面) 。 我还没有这样做, 想知道如何做? 我该添加什么代码? 代码后面应该添加什么代码?

Update Want to know the below Javascript will do what I am looking for? I am still checking it. If anyone has any feedback, please update.

function postToURL(url, values) {
    values = values || {};

    var form = createElement("form", {action: url,
                                      method: "POST",
                                      style: "display: none"});
    for (var property in values) {
        if (values.hasOwnProperty(property)) {
            var value = values[property];
            if (value instanceof Array) {
                for (var i = 0, l = value.length; i < l; i++) {
                    form.appendChild(createElement("input", {type: "hidden",
                                                             name: property,
                                                             value: value[i]}));
                }
            }
            else {
                form.appendChild(createElement("input", {type: "hidden",
                                                         name: property,
                                                         value: value}));
            }
        }
    }
    document.body.appendChild(form);
    form.submit();
    document.body.removeChild(form);
}
</script>
问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签