Skip to content

Instantly share code, notes, and snippets.

@abergs
Created September 2, 2010 11:42
Show Gist options
  • Save abergs/562184 to your computer and use it in GitHub Desktop.
Save abergs/562184 to your computer and use it in GitHub Desktop.
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}:myBtn runat=server></{0}:myBtn>")> _
Public Class myBtn
Inherits LinkButton
< _
Bindable(True), _
Category("Appearance"), _
DefaultValue(""), _
Description("Linkbutton med ikon & text."), _
Localizable(True) _
> _
Public Overrides Property Text() As String
Get
Dim s As String = CType(ViewState("Text"), String)
Return If((s Is Nothing), "Knapp", s)
End Get
Set(ByVal value As String)
ViewState("Text") = value
End Set
End Property
< _
Bindable(True), _
Category("Appearance"), _
DefaultValue(""), _
Description("Ikonen."), _
Localizable(True) _
> _
Public Overridable Property iconUrl As String
Get
Dim url As String = ViewState("Ikon")
If url Is Nothing Then url = ""
Return url
End Get
Set(ByVal value As String)
ViewState("Ikon") = value
End Set
End Property
Protected Overrides Sub RenderContents( _
ByVal writer As HtmlTextWriter)
Dim btn As New LinkButton
btn.CssClass = "Btn"
btn.PostBackUrl = "main.aspx"
'writer.WriteEncodedText(Text)
Dim span As New HtmlControls.HtmlGenericControl("span")
span.InnerText = Text
Dim image As New Image
image.ImageUrl = iconUrl
If image.ImageUrl = "" Then
image.Visible = False
End If
btn.Controls.Add(image)
btn.Controls.Add(span)
btn.RenderControl(writer)
' Dim displayUserName As String = innerText
'If Context IsNot Nothing Then
' Dim userName As String = Context.User.Identity.Name
' If Not String.IsNullOrEmpty(userName) Then
' displayUserName = userName
' End If
'End If
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment