Categories
Coding

Adding Metadata Progmattically

Dim meta As HtmlMeta = New HtmlMeta()
meta.HttpEquiv = "refresh"
meta.Content = "600"
Page.Header.Controls.Add(meta)

Categories
Coding

Detecting Mobile Devices with ASP.NET

I’ve no imediate use for this code, but I know wthat it will be useful in the future – especially as the number of user’s accessing websites via mobile phones and PDAs grow.

Taken from a post by truelove.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim Browser_obj As System.Web.Mobile.MobileCapabilities = CType(Request.Browser, System.Web.Mobile.MobileCapabilities)
If Browser_obj.Browser = "Pocket IE" Then
Label1.Text = "the is Pocket PC"
ElseIf Browser_obj.Browser = "IE" Then
Label1.Text = "Microsoft Internet Explorer"
ElseIf Browser_obj.Browser = "Phone.com" Then
Label1.Text = "the is Openwave"
End If
End If
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim browser As System.Web.Mobile.MobileCapabilities = CType(Request.Browser, System.Web.Mobile.MobileCapabilities)
If browser.ScreenCharactersWidth < 20 Then Label1.Text = "short text message" Else Label1.Text = "long text message" End If End If End Sub

Categories
Coding

Strip HTML Tags from a String

Private Function ConvertHtmlToPlainText(ByVal htmlText As String) As String
Return Regex.Replace(htmlText, "<[^>]*>", String.Empty)
End Function

Categories
Coding

Converting C# to VB.Net

Thanks to a reply to one of my posts within the SubSonic forums, I was pointed to this very nifty utility at Developer Fusion – a tool that will automatically convert C# code to VB.Net and back again.

Categories
Coding

Intellisense within SubSonic

I struggled for a while this morning while trying to add SubSonic to a new web project – I was trying to fathom why, when I had followed all of my notes, the intellisence for the build provider was not displaying. In the end, the issue was solved with the help of this post.

Addendum:

Categories
Design & UI

Islands of Richness with Silverlight on an ASP.NET page

I stumbled across this great tutorial by Brad Adams, titled ‘Islands of Richness with Silverlight on an ASP.NET page‘. Step by step it walks you through using and customising the ASP.NET MediaPlayer control and shows your how video can be added to an ASP.NET website.

Addendum: On the subject of Silverlight, this is an interesting development from Microsoft.

Categories
Coding

Accessing the Html Header in ASP.NET 2.0

Posting this for future reference:

Dim header As Web.UI.HtmlControls.HtmlHead
header = TryCast(Me.Page.Header, Web.UI.HtmlControls.HtmlHead)
If (header IsNot Nothing) Then
Dim link As New HtmlLink
link.Attributes.Add("type", "text/css")
link.Attributes.Add("rel", "stylesheet")
link.Attributes.Add("media", "screen")
link.Attributes.Add("href", "~/style.css")
header.Controls.Add(link)
End If

Categories
Coding

ASP.Net Paths

Just posting a link to this article by Rick Strahl as its one I seem to refer to time after time…

Categories
Coding

Implementing Waiting Pages in ASP.NET

Just adding this for future reference (I know a project it would be perfect for).

Categories
Coding

The ASP.Net Web Config File

Posting this for future reference…