Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hi, I want to remove parent controls without deleting its children controls from container. how can I accomplish this in asp.net c#?
  2.  
  3.  
  4.  
  5. public static Control FindChildControl(Control startingControl, string id)
  6.         {
  7.             Control found = null;
  8.             foreach (Control activeControl in startingControl.Controls)
  9.             {
  10.                 found = (Control)activeControl;
  11.                 if (found == null || (string.Compare(id, found.ID, true) != 0))
  12.                 {
  13.                    
  14.                     if (object.ReferenceEquals(found.GetType(), typeof(HtmlGenericControl))
  15.                         && ((HtmlGenericControl)found).Attributes["class"] == "result-listingext"
  16.                         && ((HtmlGenericControl)found).Attributes["id"] == "newsright")
  17.                     {
  18.                        
  19.                         return found.Parent;
  20.                        
  21.                     }
  22.                    
  23.                     found = FindChildControl(activeControl, id);
  24.  
  25.                 }
  26.                 if (found != null)
  27.                 {
  28.                     break;
  29.                 }
  30.             }
  31.  
  32.             return found;
  33.         }
  34.  
  35.  
  36. //below is the output which is being generated, and I want to remove this span from dynamically generated html code
  37.  
  38.  
  39. <span><ul id="abc" class="result-listingext" id="newsright"><li>Hello 1</li><li>Hello 1</li></ul></span>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement