[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating server control

Posted on 2011-05-12
2
Medium Priority
?
310 Views
Last Modified: 2012-08-30
Hi! is this the correct way of doing thing?

Creating a specific css class for a specific control, Is the correct implementation? or do you have any other suggestion...

Your comment is greatly appreciated.

Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

<Serializable()> _
Public Class SmartItems
    Inherits WebControl


    Private _CSSLocation As String = ""
    <Browsable(True)> _
    Public Property CSSLocation() As String
        Get
            Return _CSSLocation
        End Get
        Set(ByVal value As String)
            _CSSLocation = value
        End Set
    End Property

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        MyBase.Render(writer)

        'Creating a specific css class for a specific control, Is the
        'correct implementation?
        writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css")
        writer.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet")
        writer.AddAttribute(HtmlTextWriterAttribute.Href, _CSSLocation)
        writer.RenderBeginTag(HtmlTextWriterTag.Link)

        writer.AddAttribute(HtmlTextWriterAttribute.Class, "MainContainer")
        writer.RenderBeginTag(HtmlTextWriterTag.Div)
        writer.RenderBeginTag(HtmlTextWriterTag.Span)
        writer.RenderEndTag()
        writer.RenderEndTag()
    End Sub
End Class

Open in new window

0
Comment
Question by:PagodNaUtak
2 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 2000 total points
ID: 35745107
0
 
LVL 8

Author Comment

by:PagodNaUtak
ID: 35745180
Nice article, but what I need to know is the way I render the CSS inside the control.

Is this the correct approach? how do I implement the CSS is it inside the control or in the page?
0

Featured Post

Independent Software Vendors: 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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 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