c# - How to sort controls at runtime in ASP.NET -


How can I control runtime in ASP.Net for example, for example, in my web page in the following order

  • textbox3
  • I have three text boxes

  • textbox1
  • textbox3
  • Based on the order of these controls

  • Textbox2
  • textbox1
  • This is just an example, any thoughts? / p>

    Finally I have found a solution and I will explain it in detail

    A "panel control" and it is called "MyPlanel" and puts all the controls you want to support

      & lt; Asp: panel id = "mypanel" runat = "server" & gt; & Lt; Asp: panel id = "dock1" runat = "server" & gt; This is the first module & lt; / Asp: panel & gt; & Lt; Asp: panel id = "dock2" runat = "server" & gt; This is the second module & lt; / Asp: panel & gt; & Lt; ASP: panel id = "doc 3" runat = "server" & gt; This is the third module & lt; / Asp: panel & gt; & Lt; / ASP: Cell & gt;  

    The output will be

    this is the first module

    this is the second module

    this is the third module

    So what should I do to change their order, let me see, I have created three panels to act like a container for the dock, my code would be

      & Lt; Asp: Panel id = "myPanel" runat = "server" & gt; & Lt; ASP: Panel ID = "Container 1" Runat = "Server" & gt; & Lt; / Asp: panel & gt; & Lt; ASP: Panel ID = "Container 2" Runat = "Server" & gt; & Lt; / Asp: panel & gt; & Lt; ASP: Panel ID = "Container 3" Runat = "Server" & gt; & Lt; / Asp: panel & gt; & Lt; Asp: panel id = "dock1" runat = "server" & gt; This is the first module & lt; / Asp: panel & gt; & Lt; Asp: panel id = "dock2" runat = "server" & gt; This is the second module & lt; / Asp: panel & gt; & Lt; ASP: panel id = "doc 3" runat = "server" & gt; This is the third module & lt; / Asp: panel & gt; & Lt; / ASP: Cell & gt;  

    There is something like this in my back code

    This will remove the Doc1 control from the mapping and put it in the container 3

     < Code> control MyCtrl1 = myPanel.FindControl ("Doc1"); Control Container Ctrl 1 = myPanel.FindControl ("container3"); MyCtrl1 Valid = true; MyPanel.Controls.Remove (myCtrl1); ContainerCtrl1 Control. Add (myCtrl1);  

    And you can manage these things from a database or cookie based on user preferences

    Best regards

    < / Html>

    Comments