开发者

jQuery load and datalist linkbutton not posting back

开发者 https://www.devze.com 2023-02-08 23:14 出处:网络
I am loading an aspx page into a div using jquery.load(开发者_运维百科).The aspx page loaded into the div has a datalist. Each datalist item has a linkbutton.My problem is that the linkbutton is not c

I am loading an aspx page into a div using jquery.load(开发者_运维百科). The aspx page loaded into the div has a datalist. Each datalist item has a linkbutton. My problem is that the linkbutton is not causing a postback though. Strangely, if I change the linkbutton to a button, it does postback. Also, when loading the page normally (not from a jquery.load event), the linkbutton performs correctly.

What is it that causes the linkbutton to not cause a postback when loaded this way? And is there a better way to handle this?

Thanks in advance,

IUJPJ


LinkButton renders a __doPostBack() JS method call, whereas a Button renders a submit button by default.

When replacing the UI with JQuery.load, scripts inside the content do not automatically parse and run. That's probably the issue here.

HTH.


+1 on what Brian said. Is there a better way to handle it? I can think of a couple of ways:

  1. convert the postback events to a handler. Then you can wire your dynamically loaded linkbuttons to regular links and use jquery ajax to post to your handler.

  2. You could load your aspx page as an iframe

I think the 1st option is more elegant but requires more work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号