简体   繁体   English

回发和UpdatePanel

[英]Postback And UpdatePanel

I recently learned you can do a postback from javascript using 我最近了解到您可以使用以下方法从javascript执行回发

__doPostBack('#<%=LinkButton.UniqueID%>', '')

This method worked well for me, even with updatepanels but now I added another LinkButton and tried to do a postback using the method above. 即使使用updatepanels,此方法也对我来说效果很好,但是现在我添加了另一个LinkBut​​ton并尝试使用上述方法进行回发。 It works but the page refreshes. 它可以工作,但是页面会刷新。

I added this LinkButton to an updatepanel and set a trigger. 我将此LinkBut​​ton添加到了updatepanel并设置了一个触发器。 When I normally click on the LinkButton , it doesn't refresh, but when I try the java postback, it does. 通常,当我单击LinkBut​​ton时,它不会刷新,但是当我尝试Java回发时,它会刷新。


*Got it to work if I write ctl00$ContentPlaceHolder1$LinkButton *如果我写ctl00 $ ContentPlaceHolder1 $ LinkBut​​ton可以正常工作

But this way isnt good for me because I can't change it everytime I move the control 但是这种方式对我不利,因为每次移动控件时都无法更改它

I notice here that you have add the # symbol. 我在这里注意到您已经添加了#符号。 This used on jQuery, not here, just remove it and its work. 这是在jQuery上使用的,不在此处,只需删除它及其工作即可。

__doPostBack('<%=LinkButton.UniqueID%>', '')

Use the ClientIDMode attribute on your link button, set it to 'static'. 使用链接按钮上的ClientIDMode属性,将其设置为“静态”。

Should do the trick for you :-) 应该为你做把戏:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM