gpt4 book ai didi

javascript - 在服务器端检索 anchor 的颜色

转载 作者:行者123 更新时间:2023-11-30 05:36:42 25 4
gpt4 key购买 nike

我正在检索服务器端 html anchor 控件的颜色。以下是我试过的代码

设计:

<a id="lkdelete" onclick="SingleDel(this);" runat="server" style="font-weight:bold ">Delete</a>

Javascript:

function SingleDel(ctrl)
{
var row=ctrl.parentNode.parentNode;//to get row containing image
var rowIndex=row.rowIndex;//row index of that row.
var hsingle_del=document.getElementById('<%hsingle_del.ClientId %>');
hsingle_del.value=rowIndex;
var modalPopupBehaviorCtrl = $find('bmpe');
modalPopupBehaviorCtrl.set_PopupControlID("pnlPopup");
modalPopupBehaviorCtrl.show();
}

Vb.Net:

    Dim pid As String = ""
For Each r As GridViewRow In gridview.Rows
Dim lnk As HtmlAnchor = CType(r.Cells(1).FindControl("lkdelete"), HtmlAnchor)

If lnk.Style("Color") = "Red" Then
pid = CType(r.FindControl("lblposid"), Label).Text
End If
Next

此处 gridview 的第一行颜色为红色。但它返回“”。有什么解决办法吗?

最佳答案

对您的代码进行少量更改。在您的页面上添加隐藏字段。

function SingleDel(ctrl)
{
var rowIndex=ctrl.offsetParent.parentNode.rowIndex-1;
var hsingle_del=document.getElementById('<%=hsingle_del.ClientId %>');
hsingle_del.value=rowIndex;
var modalPopupBehaviorCtrl = $find('bmpe');
modalPopupBehaviorCtrl.set_PopupControlID("pnlPopup");
modalPopupBehaviorCtrl.show();
}

vb(代替 for 循环)

pid = CType(gridview.Rows(hsingle_del.Value).FindControl("lblposid"), Label).Text

关于javascript - 在服务器端检索 anchor 的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23288040/

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