gpt4 book ai didi

asp.net - jquery 序列化和 .net 控件

转载 作者:行者123 更新时间:2023-12-01 05:02:37 24 4
gpt4 key购买 nike

我将 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());

它在窗口上打印 ddFirmaAd 客户端名称 ="ct100%24ct100%24ContentPlaceHolder1%24ContentPlaceHolder1%24ddFirmaAd = 2 "

我想在代码后面获取 ddFirmaAd.selectedValue

string value = request.queryString("ddFirmaAd");

但控件名称 = ct100%24ct100%24ContentPlaceHolder1%24ContentPlaceHolder1%24ddFirmaAd

如何使用serialize()和.net控件?

最佳答案

string value = request.QueryString(ddFirmaAd.ClientID); 怎么样?

但是如果您将这些值传递到不同的页面,您可以像这样破解它:

字符串值 = GetValueById("ddFirmaAd");

private string GetValueById(string endsWith)
{
var qs = HttpContext.Current.Request.QueryString;
foreach(var key in qs)
{
string skey = key.ToString();
if(skey.EndsWith(endsWith))
{
return qs[skey];
}

}
return string.Empty;
}

并不是说它是正确的。根据当前提供的问题描述,根本无法想出更好的方案。

您可以配置ClientIDMode静态,但维护唯一 ID 成为您的责任,并且可能会导致难以发现客户端错误。

关于asp.net - jquery 序列化和 .net 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8671677/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com