Solved

ASP.NET Label control to render text as <p> tag instead of <span>

Posted on 2010-11-09
3
1,111 Views
Last Modified: 2012-05-10
I want a label control to render text as <p> tag instead of <span>.
I tried to create a server control inheriting label control as mention in the article below
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_21634031.html

But it does not work, the control is ok i included it in my project but it does not produce the desired result, it still is <span> tag

My code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls


<DefaultProperty("Text"), ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")>
Public Class ServerControl1
    Inherits System.Web.UI.WebControls.Label

    <Bindable(True), Category("Appearance"), DefaultValue(""), Localizable(True)>
    Protected  Function get_TagKey() As HtmlTextWriterTag
        If Me.AssociatedControlID.Length <> 0 Then
            Return HtmlTextWriterTag.P
        End If
        Return MyBase.TagKey
    End Function

End Class

Open in new window

0
Comment
Question by:vickytaurus
3 Comments
 
LVL 13

Accepted Solution

by:
devlab2012 earned 500 total points
ID: 34093589
See the comment by SomeNewKid in the following link:

http://forums.asp.net/t/938320.aspx
0
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 34093665
I'm curious if this will fix it or not:

Public Class ServerControl1
    Inherits Label
    Protected Overrides ReadOnly Property TagKey() As HtmlTextWriterTag
        Get
            If AssociatedControlID.Length > 0 Then
                Return HtmlTextWriterTag.P
            End If
            Return TagKey
        End Get
    End Property
End Class
0
 

Author Comment

by:vickytaurus
ID: 34094307
Dan7el, the code does not help.
I am accepting devlab2012's answer as solution although that was not what i was looking for.

Anyways thanks for the prompt response.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

832 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