简体   繁体   English

从多个用户控件加载和检索数据

[英]Loading & Retrieving data from multiple user controls

I have multiple user controls on the page that are used primarily for data entry purposes. 我在页面上有多个用户控件,这些控件主要用于数据输入。 When a product is loaded, I need to load the product data into all those user controls and retrieve data when I need to save the product. 加载产品时,我需要将产品数据加载到所有这些用户控件中,并在需要保存产品时检索数据。 The user controls are not visible to the user directly, instead user would click on a link and the user control will open up in a modal popup. 用户控件对用户不直接可见,而是用户单击链接,然后将在模式弹出窗口中打开用户控件。

Currently the way I'm doing this is, I've loaded all the user controls on the page in separate div controls, and showing the modal popup when the link is clicked. 目前,我的操作方式是,将页面上的所有用户控件分别加载到单独的div控件中,并在单击链接时显示模式弹出窗口。 I'm sure loading all the user controls on the page is not a good idea. 我确定在页面上加载所有用户控件不是一个好主意。 Is there a better way to handle this? 有没有更好的方法来解决这个问题? I think we can show the markup using JSON with jQuery - but how can I load and retrieve the data using that? 我认为我们可以使用JSON和jQuery显示标记-但是如何使用该标记加载和检索数据? Can someone help please? 有人可以帮忙吗?

Thanks. 谢谢。

Sounds like a case for AJAX. 听起来像是AJAX的案例。 You could use an UpdatePanel within the div that defines the modal dialog. 您可以在div内使用UpdatePanel来定义模式对话框。 From the click handler for whatever control brings up a particular modal, you can dynamically replace one usercontrol with another in that UpdatePanel, pre-populate the usercontrol's data, then show a single modal that could be anything. 通过单击处理程序中的任何控件,只要出现一个特定的模式,您都可以在该UpdatePanel中将一个用户控件动态替换为另一个用户控件,预先填充该用户控件的数据,然后显示一个可以为任意形式的模式。 Doesn't have to be a modal either; 也不必一定是模态的。 you could set up the UI with tab-like controls that switch between these UserControls in an always-visible div. 您可以使用类似标签的控件来设置用户界面,这些控件可以在始终可见的div中在这些UserControl之间切换。

For a simpler approach, you could keep your Usercontrols in a div that is initially hidden by JQuery. 对于更简单的方法,您可以将Usercontrols保留在最初由JQuery隐藏的div中。

On postback, ie. 在回发,即。 when the user clicks the button/link for a particular product you can populate all your controls in a standard ASP.Net way so they're ready to display and then call a bit of JS/JQuery to show the div as a modal dialog. 当用户单击特定产品的按钮/链接时,可以以标准ASP.Net方式填充所有控件,以便它们可以显示,然后调用一些JS / JQuery将div显示为模式对话框。

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

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