Loop foreach in asp.net for Multiview TextBox.Enabled

555 Views Asked by At

Im trying to change my code from C# to ASP.NET (codebehind c#).

In my windows application i have loop:

 foreach (TabPage tp in tabControl1.TabPages)
       {
           foreach (Control textboxy in tp.Controls)
           {
               if (textboxy is TextBox)
               {

                   if (textboxy.Enabled)
                   {

                       if (!string.IsNullOrWhiteSpace(textboxy.Text))
                       {
                          ....

Now, in my new web application asp i'm using multiview instead of tabcontrol. I have problem at the beginning:

 foreach (View tp in MainView)        
       {
          foreach (Control textboxy in tp.Controls)
        {
            if (textboxy is TextBox)
            {
                if (textboxy.Enabled)
                {

(i left all variables the same) Error is on

   textboxy.Enabled

it seems there is no definition for 'Enabled' but only in this loop. What i'm doing wrong ?

1

There are 1 best solutions below

0
On BEST ANSWER

Well, i guess i must answer on my question :)

 foreach (View tp in MainView.Views)
    {
        foreach (Control textboxy in tp.Controls)
        {
            if(textboxy is TextBox)
            {
                if((textboxy as TextBox).Enabled)
                {

                    if (!string.IsNullOrWhiteSpace((textboxy as TextBox).Text))

It's works for me. Maybe it will help for somebody else:)