[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2010-11-09
3
Medium Priority
?
1,127 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 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