Solved

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

Posted on 2010-11-09
3
1,113 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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