[英]Javascript doPostBack in jquery click event
I have an existing js function that is fired as a click event on all 'a' elements... 我有一个现有的js函数,它会在所有'a'元素上作为点击事件触发...
$(document).ready(function hideRanges() {
$('a').click(function (event) {
$('.ranges, #UpdatePanel').hide();
});
}); });
When an 'a' tag is clicked, 2 div classes are hidden. 单击“ a”标签时,将隐藏2个div类。 It works.
有用。
I also need this same click event to unbind a SqlDataSource from a GridView in asp.net. 我还需要相同的click事件,以从asp.net中的GridView取消绑定SqlDataSource。 Here is the unbind code behind...
这是背后的解除绑定代码...
protected void unBind_Click(object sender, EventArgs e)
{
int rowCount = GridView2.Rows.Count;
if (rowCount > 0)
{
GridView2.DataSource = null;
GridView2.DataBind();
RowCount.Text = GridView2.Rows.Count.ToString();
}
}
It also works. 它也可以。 I have hidden this button, though, and need it to fire with the js click event above.
不过,我已经隐藏了此按钮,并且需要它与上面的js click事件一起触发。
I have tried things such as... 我已经尝试过诸如...
$(document).ready(function hideRanges() {
$('a').click(function (event) {
$('.ranges, #UpdatePanel').hide();
javascript: __doPostBack('<%= unBindGrid.UniqueID%>', '');
});
}); });
But it does not seem to work properly. 但是它似乎无法正常工作。
Any advice much appreciated. 任何建议,不胜感激。 Thank you!
谢谢!
I got this working by routing to the ID of the asp:button... 我通过路由到asp:button的ID来完成此工作...
$(document).ready(function hideRanges() {
$('a').click(function (event) {
$('.ranges, #UpdatePanel').hide();
$("input[id$='unBindGrid'").click();
});
}); });
Thank you! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.