Solved

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

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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.…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now