开发者

How to generate asp.net textbox accoring to the digit displays in label text?

开发者 https://www.devze.com 2023-01-25 23:39 出处:网络
If in the label the default text is 10 then ten textbox controls will be generated in webform 开发者_如何学Python...

If in the label the default text is 10 then ten textbox controls will be generated in webform 开发者_如何学Python...

Can anybody did this in VB.NET ?


Look at add control. You simply use a loop based on the counter in the label then you say myWebForm.Controls.Add(txtBox); where txtBox is:

Dim txtBox as TextBox

Sure here is some code:

Dim count as Integer

count =  CType(Me.myLabel.Text, Integer)

For i as Integer=0 to count-1
  txtBox = new TextBox()
  txtBox.ID = "txt" & i.ToString()
  myForm.Controls.Add(txtBox)
Next i
0

精彩评论

暂无评论...
验证码 换一张
取 消