我正在尝试获取href的值,因为我需要在查询字符串中传递一个变量
<a id="CA" class="CA" href='<%#"mysecondpage.aspx?ID=" + Td1.InnerText %>'
onclick="return popitup(this.href)" runat="server">comment</a>
我必须打开一个弹出窗口,其中“MySecondPage”应该以查询字符串中的值打开,但这个.href返回空值,我不知道为什么它不能工作,就像它在itemtemplate(gridview)中工作一样,我使用了table并用angularJS Repeat。
这是我的弹出功能:
function popitup(url) {
alert(url);
// window.open(url+id,'popup', 'width=700,height=800,scrollbars=no,resizable=no');
return false;
}
您正在使用数据绑定表达式<%#%>
。因此您必须在Page_Load中显式调用databind()
。
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
}
如果您正在使用Jquery,
试试这个我希望它会对您有所帮助
$(document).ready(function(){
$('#CA').on('click' function(event){
event.preventDefault();
var url = $(this).attr('href');
alert(url);
});
});
如果不工作,请与我联系