Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Clear the TextBox Controls in a Panel
    text
    copied!<p>I want to empty textbox controls in a Panel. Please explain.</p> <p>below is my code:</p> <pre><code>&lt;asp:Panel ID="Panel_CreateLead" runat="server" Visible="false" BackColor="#eff2f6" Width="98%"&gt; &lt;asp:Literal ID="LiteralNoLead" runat="server" Text="&lt;span style='color:red'&gt;No Lead Exists. Please fill the Lead Template to Create New Lead.&lt;/span&gt;"&gt;&lt;/asp:Literal&gt; &lt;asp:Table ID="Table_CreateLead" runat="server" Width="98%" CellSpacing="1" CellPadding="1" Font-Names="Tahoma" BorderColor="#eff2f6" BorderStyle="Dashed"&gt; &lt;asp:TableHeaderRow HorizontalAlign="Center"&gt; &lt;asp:TableHeaderCell Text="Lead Template" Font-Bold="true" ColumnSpan="4" Font-Size="Large" /&gt; &lt;/asp:TableHeaderRow&gt; &lt;asp:TableRow ID="TableRow11" runat="server"&gt; &lt;asp:TableCell Text="General" Font-Bold="true" ForeColor="Blue"&gt;&lt;/asp:TableCell&gt; &lt;/asp:TableRow&gt; &lt;asp:TableRow ID="TableRow1" runat="server"&gt; &lt;asp:TableCell Text="Topic"&gt; &lt;asp:Literal ID="Literal_Topic" Text="&lt;span style='color:red'&gt;*&lt;/span&gt;" runat="server" /&gt; &lt;/asp:TableCell&gt; &lt;asp:TableCell ColumnSpan="3"&gt; &lt;asp:TextBox ID="TextBox_leadname" Width="80%" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator_TextBox_leadname" runat="server" ControlToValidate="TextBox_leadname" ValidationGroup="LeadVaidation" ErrorMessage="Enter Topic" /&gt; &lt;/asp:TableCell&gt; &lt;/asp:TableRow&gt; &lt;asp:TableRow ID="TableRow23" runat="server"&gt; &lt;asp:TableCell Text="Currency" &gt;&lt;/asp:TableCell&gt; &lt;asp:TableCell&gt; &lt;asp:DropDownList ID="DropDownList_Currency" runat="server"&gt; &lt;/asp:DropDownList&gt; &lt;/asp:TableCell&gt; &lt;asp:TableCell Text="No. of Employees" &gt;&lt;/asp:TableCell&gt; &lt;asp:TableCell&gt; &lt;asp:TextBox ID="TextBox_Employees" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;/asp:TableCell&gt; &lt;/asp:TableRow&gt; &lt;asp:TableRow&gt; &lt;asp:TableCell&gt; &lt;asp:Button ID="Button_lead" runat="server" Text="Submit" OnClick="create_lead" ValidationGroup="LeadVaidation"/&gt; &lt;/asp:TableCell&gt; &lt;asp:TableCell&gt; &lt;asp:Literal ID="Literal_lead" runat="server"&gt;&lt;/asp:Literal&gt; &lt;/asp:TableCell&gt; &lt;/asp:TableRow&gt; &lt;/asp:Table&gt; &lt;/asp:Panel&gt; </code></pre> <p>I have used a method clearText(Panel_CreateLead); on page load which does not work.</p> <p>the code used in cleartext():</p> <pre><code>private void clearText(Panel PanelID) { foreach (Control c in PanelID.Controls) { if (c is TextBox) { TextBox questionTextBox = c as TextBox; if (questionTextBox != null) { questionTextBox.Text = ""; } } } } </code></pre> <p>All these are not working. Please help.</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