Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating User Controls based on result of another control
    primarykey
    data
    text
    <p>I'm new to ASP.NET C# and trying to accomplish the following:</p> <p>Have a Default.aspx page with two user controls (Control1.ascx and Control2.ascx) Both user controls are within UpdatePanels.</p> <p>Need the TextBox on the second user control disabled until the TextBox on the first control has been validated. Once validated, TextBox on user control2 needs to be enabled.</p> <p>These user controls will be re-used on multiple pages. Help is appreciated. If I need to post some code let me know.</p> <p>Here's code sample:</p> <p><strong>Default.aspx</strong></p> <pre><code>&lt;%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;%@ Register src="Control1.ascx" tagname="CTL1" tagprefix="uc1" %&gt; &lt;%@ Register src="Control2.ascx" tagname="CTL2" tagprefix="uc2" %&gt; &lt;uc1:CTL1 Id="CTL1" runat="Server" UpdateMode="Conditional"/&gt; &lt;uc2:CTL2 Id="CTL2" runat="Server" UpdateMode="Conditional"/&gt; </code></pre> <p><strong>Default.aspx.cs</strong></p> <pre><code>public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } </code></pre> <p><strong>Control1.ascx</strong></p> <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control1.ascx.cs" Inherits="Control1" %&gt; &lt;asp:UpdatePanel ID="UpdatePanel_Fld1" runat="server" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;asp:TextBox ID="TextBox_Fld1" runat="server" Enabled="True" &gt;&lt;/asp:TextBox&gt; &lt;asp:ImageButton ID="ImageButton_ValidateFld1" runat="server" ImageUrl="~/images/validate.jpg" onclick="ImageButton_ValidateFld1_Click" /&gt; &lt;asp:Label ID="LabelFld1Summary" runat="server" &gt;&amp;nbsp;&lt;/asp:Label&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p><strong>Control1.ascx.cs</strong></p> <pre><code> public partial class Control1 : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } public void ImageButton_ValidateFld1_Click(object sender, ImageClickEventArgs e) { LabelFld1Summary.Text = "Validated"; } } </code></pre> <p><strong>Control2.ascx</strong></p> <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control2.ascx.cs" Inherits="Control2" %&gt; &lt;asp:UpdatePanel ID="UpdatePanel_Fld2" runat="server" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;asp:TextBox ID="TextBox_Fld2" runat="server" Enabled="False"&gt;&lt;/asp:TextBox&gt; &lt;asp:ImageButton ID="ImageButton_ValidateFld2" runat="server" ImageUrl="~/images/validate.jpg" onclick="ImageButton_ValidateFld2_Click" /&gt; &lt;asp:Label ID="LabelFld2Summary" runat="server" &gt;&amp;nbsp;&lt;/asp:Label&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p><strong>Control2.ascx.cs</strong></p> <pre><code>public partial class Control2 : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } public void ImageButton_ValidateFld2_Click(object sender, ImageClickEventArgs e) { LabelFld2Summary.Text = "Validated"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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