Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在锚点上添加onclick属性_C#_Attributes_Anchor - Fatal编程技术网

C# 在锚点上添加onclick属性

C# 在锚点上添加onclick属性,c#,attributes,anchor,C#,Attributes,Anchor,我正试图以这种方式在锚标记上添加onclick属性 chq.Attributes["Onclick"] = "http://172.17.0.221:81/CheckVerification1.aspx?id=" + Session["U_EMAIL"].ToString(); 这是我的锚标签 <a id="chq" runat="server" target="_blank">Cheque</a> 支票 但是这种方法是不可行的,任何人都可以给出替代方法来做到这一

我正试图以这种方式在锚标记上添加onclick属性

chq.Attributes["Onclick"] = "http://172.17.0.221:81/CheckVerification1.aspx?id=" + Session["U_EMAIL"].ToString();
这是我的锚标签

<a id="chq" runat="server"  target="_blank">Cheque</a>
支票
但是这种方法是不可行的,任何人都可以给出替代方法来做到这一点

chq.Attributes["src"] = "http://172.17.0.221:81/CheckVerification1.aspx?id=" + Session["U_EMAIL"].ToString();
Html

<a id="chq" runat="server" src="" target="_blank">Cheque</a>
支票

如果要在onclick事件触发时重定向,则必须使用锚定标记的src属性,在代码后面,可以通过这种方式向原始html元素添加属性

 chq.Attributes.Add("src", "http://172.17.0.221:81/CheckVerification1.aspx?id=");

是否要从代码隐藏中添加属性?是的,我想将会话电子邮件id作为querystring获取到另一个页面无需添加
onclick
属性。最好的方法是使用
src
属性。尝试使用
chq.Attributes.Add(“src”),“http://172.17.0.221:81/CheckVerification1.aspx?id=“+会话[“U_电子邮件”].ToString())
@user1645793::在使用第一个解决方案时,页面呈现后,
src
属性的值是多少?我在页面加载事件中使用上述代码,但这几乎不是working@user1645793::将
src
更改为
href