C# - 从母版页重新加载选项卡
我的母版页中有一个 FromDate 和 ToDate 文本框以及一个提交按钮。我有 4 个选项卡,其中包含 4 个不同 URL 的链接,显示各种报告。
现在更改日期并单击提交按钮,我可以根据日期更改更新/重新加载报告(选项卡)吗?
预先非常感谢:)
I have a FromDate and ToDate textboxes and a submit button in my Master page. I have 4 tabs with links for 4 different URLs displaying various reports.
Now on change of Dates and click of submit button, can I update/reload the reports (tabs) based on date change?
Thanks a lot in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议将您的起始日期和提交按钮移至用户控件。然后,您可以将其放在每个报告上,公开并连接控件上已更改的事件,并公开当前日期文本框的属性以弹出到报告中。
在 Visual Studio 中创建一个用户控件。如果您不确定如何执行此操作,请尝试此链接。
使用文本框填充用户控件。像这样的东西:
以及该控件背后的代码。您需要公开一个事件和两个属性,它们可能如下所示:
在您的 .aspx 页面中,您需要注册控件,这可能如下所示:
然后实际将其放在页面上
:然后连接后面的代码来处理更新事件:
在适当的地方更改名称和格式,但这应该会给您一个好主意。
I would suggest moving your from-to dates and submit button to a user control. You can then put that on each report, expose and wire up changed events on your control and expose properties for your from-to date textboxes to pop into your report.
In Visual Studio create a user control. If you are unsure how to do this try this link.
Populate the user control with your text boxes. Something like this:
And the code behind for that control. You'll need to expose an event and the two properties, which might look like this:
In your .aspx page you'll need to register the control, which might go something like this:
And then actually put it on the page:
And then wire up the code behind to handle the update events:
Change the names and formatting where appropriate, but this should give you a good idea.
此外,您还可以从母版页公开 Date 控件并通过 Page.Master 属性访问它们。您需要转换为母版页的特定类型才能获取其属性。
Also, you can expose the Date controls from the master page and access them through the Page.Master property. You'll need to cast to the specific type of your master page to get at it's properties.