开发者

ASP.Net create new user control using JQuery

开发者 https://www.devze.com 2023-02-05 02:04 出处:网络
I know you can can do this using MVC. But not sure if you can using Web Forms. I have a button, when clicked it will get the data then populate a repater then injects the data to other controls. This

I know you can can do this using MVC. But not sure if you can using Web Forms.

I have a button, when clicked it will get the data then populate a repater then injects the data to other controls. This works fine using postback, but it's a lit开发者_如何学JAVAtle slow and I want to do it using Ajax.

Is there a way to use JQuery to instantiate the repeater control or the user controls without using postback or using evil update panels?

Thanks!


If you create a page that handles just the repeater, and use jQuery to request that page via ajax you can set the inner html of a container to the response returned by your requested fragment.

<div id="repeater-goes-here"></div>

<script type="text/javascript">
   $(document).ready(function() {
       $.ajax('repeater.aspx', null, success: function(responseText) {
           $('#repeater-goes-here').html(responseText);
       };
   });
</script>

The 'repeater.aspx' page should contain the repeater object and the code required to populate it from data.

0

精彩评论

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