Tag prefix

  • Thread starter Thread starter Blaz Ziherl
  • Start date Start date
B

Blaz Ziherl

Hi all,

I have two ASP.NET newby questions:

1. what and why are there tag prefixes (example <asp:....)?
2. why doesn't the following code (in VB.NET) render these prefixes?

Dim myTextBox As New System.Web.UI.WebControls.TextBox
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

myTextBox.RenderControl(oHtmlTextWriter)
TextBox1.Text = oStringWriter.ToString()


Regards,
Blaz
 
blaz,

Tag prefixes are used by the asp.net compiler to identify tags that should
be processed on the server. All stardard ASP.Net control have the ASP
prefix. If you build your own controls, you can use a custom tag prefix such
as:

<blaz:newlabel id="blazlabel1" runat="server" text="" />

If you notice the rendered HTML output on the client these server controls
have been rendered as standard HTML elements such as <select>, <input>,
<img>, and so forth. Browsers such as IE and Netscape cannot parse a
<asp:label> tag, the server handles this.

For the answer to question 2. What are you trying to do?

Add a text box to a form?
Dim tbFirstName as System.Web.UI.WebControls.TextBox
Page.Controls.Add(FirstName)
Read the text of a textbox?
Dim strFirstName as String = tbFirstName.Text

HTH MikeL
 
Thanks for your answers!

About the rendering. Well I am trying to add an ASP.NET WebControls
support to my application that includes a simple HTML Editor. But
can't really figure out how could I generate <asp:...></asp:...>
formatted ASP code from any of the WebControls.

Any ideas?

Regards,
Blaz
 
Back
Top