Dim meta As HtmlMeta = New HtmlMeta()
meta.HttpEquiv = "refresh"
meta.Content = "600"
Page.Header.Controls.Add(meta)
Tag: VB.Net
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
Strip HTML Tags from a String
Private Function ConvertHtmlToPlainText(ByVal htmlText As String) As String
Return Regex.Replace(htmlText, "<[^>]*>", String.Empty)
End Function
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.
Intellisense within SubSonic
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.
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
ASP.Net Paths
Just posting a link to this article by Rick Strahl as its one I seem to refer to time after time…
Implementing Waiting Pages in ASP.NET
Just adding this for future reference (I know a project it would be perfect for).
The ASP.Net Web Config File
Posting this for future reference…