【发布时间】:2011-12-29 18:18:51
【问题描述】:
我将 jquery serialize() 与 asp.net 服务器控件一起使用。
<asp:DropDownList ID="ddFirmaAd" runat="server" Width="180" Height="25">
</asp:DropDownList>
当我打印数组时
ajaxRequest("AjaxServices/Insert.aspx", $("#aspnetForm").serialize(), $('#returnMessage'), 0, $(this));
function ajaxRequest(pageURL, queryString, putArea, timeout, disabledCtrl) {
if (disabledCtrl != null)
disabledCtrl.attr("disabled", "true");
$.ajax({
async: true,
timeout: timeout,
cache: false,
url: pageURL + "?" + queryString,
alert($("#aspnetForm").find("input,textarea,select,hidden").not("#__VIEWSTATE,#__EVENTVALIDATION").serialize());
它在 window ="ct100%24ct100%24ContentPlaceHolder1%24ContentPlaceHolder1%24ddFirmaAd = 2" 上打印 ddFirmaAd 客户端名称
我想在后面的代码中获取 ddFirmaAd.selectedValue
string value = request.queryString("ddFirmaAd");
但控件名称 = ct100%24ct100%24ContentPlaceHolder1%24ContentPlaceHolder1%24ddFirmaAd
如何使用 serialize() 和 .net 控件?
【问题讨论】:
-
@Robotsushi:ASP.NET 自动将元素的
name属性设置为完全限定的控件层次结构名称,使得它们几乎不能在 ASP.NET 服务器控件生态系统之外的代码中使用。他正在使用 jQuery 进行序列化,它使用name属性来构建表单值(因为 HTTP POST 使用name属性来识别form元素)。大概是将它们发送到不同的页面(不是具有控件的可后发页面)。因此,很难查询字符串值。 -
为什么要序列化 .net 控件? (不是批评只是对您的用例感到好奇)
-
我有动态控件列出数据库中的数据。
标签: asp.net .net jquery webforms