bob white

bob white

  • NA
  • 13
  • 82.7k

how to capture master page content controls via Linq

Jan 6 2011 5:12 PM

Hi, I have not worked with Linq, but I need to fix this piece of code. It turns out that the code above does not capture the input or div controls !
Here is the code, the problem is that the  inputControls.Count is always Zero and cannot execture any further code.
my question how can I fix the fir two list code?
and I do not know why this.Page.Form.Controls[11].Controls   // the index of 11 means
 
List<Control> inputControls = ( from Control c in this.Page.Form.Controls[11].Controls
  where c.GetType() == typeof(TextBox)
  select c ).ToList();
List<Control> divControls = ( from Control c in this.Page.Form.Controls[11].Controls
   where c.GetType() == typeof( HtmlGenericControl ) &&
   ( (HtmlGenericControl)c ).TagName == "div"
   select c ).ToList();
 
if ( inputControls.Count > 0 )
this is some code from the GUI interface
I have about 20 fields that they all have same format as this
<tr>
 <td><label>Positive MAT</label></td>
 <td><asp:TextBox runat="server" id="txtFAPositiveMAT" /></td>
 <td><div id="FAPositiveMAT" runat="server" /></td>
 <td><pre></pre></td>
</tr>

any help is appreciated.
Bob 

Answers (1)