Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic controls .ASCX vs .ASPX

Status
Not open for further replies.

Kai77

Programmer
Jun 7, 2004
77
NL
If I run the following code in an ASPX file:

Sub ShowControls()
Dim i As Integer
For i = 0 To 5
plhSurvey.Controls.Add(getTextbox(i.ToString))
Next i
End Sub

Private Function getTextbox(ByVal ID As String) As TextBox
Dim x As New TextBox
x.ID = ID
Return x
End Function

I get the result I want, it shows the textboxes with the ID I specified.
e.g. :
<input name="0" type="text" id="0" />

But when I run this same code in an .ASCX file and load this in a placeholder of an ASPX file, I don't get the ID's that I want.
e.g.:
<input name="_ctl1:0" type="text" id="_ctl1_0" />

Why does he add the _ctl1: to the name and _ctl1_ to the id? Is there anyway I can avoid this from happening? Other than to use an ASPX file instead of an ASCX ofcourse.
 
I can see how there is confussion, I mean, ASP.Net has ASPx and ASCx files, where as VB.Net has .vb and .resx files. I mean it's easy to confuse. Even the forum names, VB.Net and ASP.Net are similar, they both have .Net it them. Can you imagine the confussion if MS had called C# c.Net. Oh man oh man.

In short, go here: (The ASP.Net forum)

-Rick

----------------------

[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Ok, you mean i posted in the wrong forum. Got it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top