开发者

generating controls dynamically

开发者 https://www.devze.com 2023-04-04 02:53 出处:网络
I have this scenario where I need to generate controls dynamically. I am running a website www.UserReviewCenter.com You can start a search from home page, type in some product type like \"radar detect

I have this scenario where I need to generate controls dynamically. I am running a website www.UserReviewCenter.com You can start a search from home page, type in some product type like "radar detector". The site will give you list of products matching your search keywords. You can select a product on this page. Next page pulls user reviews that were submitted through the website plus reviews from other 3rd party sites. Now here is the challenging situation for me - there could be n number of reviews so I have to generate one label and one textbox for each review entry. Initially label will be visible and textbox will be hidden. As soon as user clicks on edit I am hiding labels and displaying textboxes. They can click on "Add" to add a new review entry then I am adding a new textbox at the bottom of the table and maintaining a flag to know that this is a new entry. I am using update panel also as you know just to reduce the whole page refresh. I know this could be a bad idea in today's jquery world.

I think this whole technique to display, add, edit user reviews is a little complicated and very fragile. I think using jquery, ajax this could be simplified so I would like to ask all the experts here on this website that what could be the other approaches that I can take to make it robust and clean.

I appreciate your respon开发者_如何学JAVAse. -Mandeep.


IMO you should make the site work without AJAX initially, using basic postbacks, controls and server-side validation.

When that's working in a robust way you can enhance the site with AJAX calls to give the user a better experience by reducing page refreshes. Everything you have talked about can be done without AJAX.

By starting off with the most complex solution and mixing AJAX and server-side calls, means your site firstly probably won't work with Javascript, and also debugging/development becomes much harder as you'll be juggling server-side bugs as well as client-side bugs.


I personally wouldn't say that using an UpdatePanel is a bad idea. If you're using a lot of .NET controls, I often find it easier to work with UpdatePanels rather than jQuery as accessing the controls themselves is easier.

UpdatePanels also have the advantage that if the user has JavaScript disabled, the site will continue to function, it will just use standard post backs rather than partial post backs.

0

精彩评论

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

关注公众号