Question Make a button which will create a row of text boxes

arahman

Member
Joined
Oct 14, 2013
Messages
5
Programming Experience
Beginner


I tried the code pasted below but it does not seem to work in vb.net. However, this creates only one text box and not where I exactly want it to be. My objective here is to create 5 text boxes under the respective labels. There will then be a button which will take in all the text inputs from the text boxes and show it in a grid view.



For i as short = 0 To 4 ' 0 1 2 3 4 = 5

    Txtdynamic = New TextBox
    Txtdynamic.Width = 20
    Txtdynamic.Visible = True
    Txtdynamic.MaxLength = 1
    Txtdynamic.Location = New Point(pos + 5, 0)
    pos += 30



This keeps giving me this error: "error BC30456: 'location' is not a member of 'System.Web.UI.WebControls.TextBox'."
Can anyone please me specify the location of the textboxes?
 
Last edited by a moderator:
First of all, you have posted this thread in the Windows Forms forum yet you are using the ASP.NET TextBox control. Is this a Windows Forms app or an Web Forms app, because that makes a significant difference?
 
It is a web form app.
I have now moved the thread to the appropriate forum.

You are trying to use code for Windows Forms which will not work in the HTML world of web applications. For a start, as you have discovered, the controls are not the same, despite having the same names when they fulfil the same role. When the user clicks a Button in an ASP.NET app, they are doing so in their own browser, disconnected from the server running the app. Either you need to use JavaScript to make the change in the browser or the page will post back to the server and then a new page will get served.

It sounds to me like you should be using a GridView, which is a control that will display a table of data and allow you to add, edit and delete rows within it. If you can provide a FULL and CLEAR of what you're trying to achieve, rather than how you're trying to achieve it, we may be able to provide more specific advice.
 

Latest posts

Back
Top