简体   繁体   中英

Dynamically Created/Copied Div in asp.net C#

For some back story on what I am trying to do. I am building a web based calculator to help me build out a phone system. The system can handle multiple sites but each site needs an unit that can handle both the number of phones on the site and the PSTN Ports on the site. The issue I have is that the site limit is 20 sites so building a DIV for each and every site is crazy. I want to find a way to make the system automate the creation of these devs on the screen ether by server side or client side actions (assuming this is going to take some issue to load server side may be better) Here is the Div I created so far:

<div id="Site1" runat="server" class="col-md-1">
        Site 1:        
        <br />Phones:<br />
        <asp:TextBox ID="Phones" runat="server" type="number" min ="1" Text="1" Width="72px" AutoCompleteType="Disabled"></asp:TextBox>
        <br />T1 Ports:<br />
        <asp:TextBox ID="T1" runat="server" type="number" min ="0" Text="0" step ="1" Width="72px" AutoCompleteType="Disabled"></asp:TextBox>
        <br />FXO Ports:<br />
        <asp:TextBox ID="FXO" runat="server" type="number" min ="0" Text="0" step="2" Width="72px" AutoCompleteType="Disabled"></asp:TextBox>
        <br />FXS Ports:<br />
        <asp:TextBox ID="FXS" runat="server" type="number" min ="0" Text ="0" step="2" Width="72px" AutoCompleteType="Disabled"></asp:TextBox>
        <hr />
    </div>

I would ideally re create it and all of the text boxes with new variables each time. I know cloning the div with nothing but data in it isn't looking to hard but creating this one time after time seems to be fooling me

It sounds like you just need to build a user control and include all of your divs in it. Then you could use something like a repeater to create as many of your div collections as you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM