Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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.</p> <p>In Visual Studio create a user control. If you are unsure how to do this try <a href="http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx" rel="nofollow">this</a> link.</p> <p>Populate the user control with your text boxes. Something like this:</p> <pre><code>&lt;div&gt; &lt;asp:Label ID="FromDateLabel" Text="From:" AssociatedControlID="FromDateTextBox" runat="server" /&gt; &lt;asp:TextBox ID="FromDateTextBox" runat="server" /&gt; &lt;asp:Label ID="ToDateLabel" Text="To:" AssociatedControlID="ToDateTextBox" runat="server" /&gt; &lt;asp:TextBox ID="ToDateTextBox" runat="server" /&gt; &lt;asp:Button ID="UpdateButton" Text="Update" runat="server" onclick="UpdateButton_Click" /&gt; &lt;/div&gt; </code></pre> <p>And the code behind for that control. You'll need to expose an event and the two properties, which might look like this:</p> <pre><code>public partial class ReportDateControl : System.Web.UI.UserControl { public event EventHandler UpdateReport; public string FromDate { get { return this.FromDateTextBox.Text; } set { this.FromDateTextBox.Text = value; } } public string ToDate { get { return this.ToDateTextBox.Text; } set { this.ToDateTextBox.Text = value; } } protected void UpdateButton_Click(object sender, EventArgs e) { if (UpdateReport != null) { UpdateReport(this, EventArgs.Empty); } } } </code></pre> <p>In your .aspx page you'll need to register the control, which might go something like this:</p> <pre><code>&lt;%@ Register Src="~/Controls/ReportDateControl.ascx" TagPrefix="myapp" TagName="ReportDateControl" %&gt; </code></pre> <p>And then actually put it on the page:</p> <pre><code>&lt;myapp:ReportDateControl id="ReportDateControl" runat="server" OnUpdateReport="ReportDateControl_UpdateReport" /&gt; </code></pre> <p>And then wire up the code behind to handle the update events:</p> <pre><code>public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void ReportDateControl_UpdateReport(object sender, EventArgs e) { Controls.ReportDateControl control = (Controls.ReportDateControl)sender; string fromDate = control.FromDate; string toDate = control.ToDate; } } </code></pre> <p>Change the names and formatting where appropriate, but this should give you a good idea.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload