Solved, c#

Posted on 2012-09-17
Last Modified: 2012-09-18
for i = 0 to 19
response.write "<input name=txtqty" & i & "><br>"

How to convert to I would like to use .net asp control in textbox as well.

Question by:solution1368
    LVL 74

    Accepted Solution

    Not the prettiest, but this would do it:

        for (int i = 0; i <= 19; i++)
            <asp:TextBox runat="server" ID="x"></asp:TextBox><br />
            x.ID = "txtqty" + i.ToString();

    Open in new window

    Do note that the Name property cannot be set for server controls due to how ASP.NET handles controls via naming containers (to ensure that controls can be uniquely identified for any particular page).

    Author Comment

    great. this is exactly what I need. Thanks
    LVL 9

    Expert Comment

    If you want functionality similar to ASP then you should rather go to MVC and not to ASP.Net Web Controls.

    MVC3 Razor Syntax. as below

       @for (int i = 0; i < 10; i++)
    			 @Html.TextBox("Textbox" + i) <br />

    Open in new window


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now