19 November 2009
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
Tagged as: VB.Net
4 November 2009
Clipboard.SetText( “Hello World!”);
Short and sweet! :)
Tagged as: C#
10 April 2009
Sometime you will need a query that will return a resultset of ranked records. The following MySQL query will do the trick:
SELECT @rownum:=@rownum+1 AS rank, companies.* FROM conpanies p, (SELECT @rownum:=0) r ORDER BY profit DESC LIMIT 20;
Tagged as: MySQL
13 February 2009
I had used this service before and spent a while trying to track down the URL again. Here it is for future reference.
http://www.skype.com/intl/en/share/buttons/wizard.html
Tagged as: Skype
14 January 2009
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>title</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
</body>
</html>
Tagged as: XHTML
14 January 2009
Private Function ConvertHtmlToPlainText(ByVal htmlText As String) As String
Return Regex.Replace(htmlText, "<[^>]*>", String.Empty)
End Function
Tagged as: VB.Net
30 September 2008
To simply returning a limited number of records while using SubSonic I added a position field to the View.
SELECT ROWID= ROW_NUMBER() OVER ( ORDER BY ProductID ASC), ProductID, [Name]
FROM Production.Product
SQL Server 2005 ROW_NUMBER()
Tagged as: SQL
5 September 2008
Yet another of my “I always use it but always forget it” posts, this time detailsing how to correctly send emails via SMTP in VB.Net.
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
Additional information can be found at System.Net.Mail.
Tagged as: VB.Net
5 March 2008
So that I don’t forget this in the future… to append additional items to a DropDownList control, use the following code.
Dim itemPosition as Integer = 0
MyDropDownList.Items.Insert(itemPosition, New ListItem("TextField", "ValueField"))MyDropDownList.SelectedIndex = 0
Tagged as: VB.Net
4 March 2008
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.
Tagged as: C#, VB.Net