Geeks With Blogs
Phil Sando February 2010 Entries
Send email from an asp.net vb page
This is the code I use to send an email from an asp.net page: Dim message As New MailMessage() message.IsBodyHtml = False message.From = New MailAddress("foo@foo.com") message.To.Add(New MailAddress("foo@foo.com")) message.Subject = ("Response from form") message.Body = ("Email message here") Dim client As New SmtpClient() client.Host = "email.foo.foo" client.Send(message) ......

Posted On Saturday, February 27, 2010 3:48 PM

Simple web form that posts XML to a web service
I am starting work on some asp.net vb pages to consume and work with web services. Part 1 was to create a web form that posts xml that a dba can paste into a textbox on an aspx page. Here is the code; Imports System.Net Imports System.IO Partial Class _Default Inherits System.Web.UI.Page Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click Dim Data As String Dim WebRequest As WebRequest Dim RequestStream As Stream Dim StreamWriter As StreamWriter Dim ......

Posted On Saturday, February 27, 2010 3:22 PM

Web.config file to password protect a directory in any ASP.net web site
Here is my web.config used to login protect a folder called administration; <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.web> <customErrors mode="Off"> </customErrors> <authentication mode="Forms"> <forms name=".ASPXAUTH" loginUrl="login.aspx" protection="All" timeout="999999"> <credentials passwordFormat="MD5"> <user name="admin" password="21232F297A57A5A74... /> </credentials> </forms> </authentication> ......

Posted On Saturday, February 27, 2010 2:52 PM

Scope Identity (short but sweet)

This handy bit of sql code returns the last identity value inserted into an identity column in the current scope and sets its value to the parameter @ID

SET @ID = SCOPE_IDENTITY()

I found this a very useful thing to get to grips with and start using in my code. For further information on scope identity hit this msdn link

 

Posted On Wednesday, February 10, 2010 11:14 AM

Adding properties to an asp.net masterpage
Exposing the property: Public Property stringproperty() As String Get Return _stringproperty End Get Set(ByVal value As String) _stringproperty = String.empty End Set End Property Accessing the property from a content page: You will need to add this line to your .aspx page in order to be able to access the property you just exposed @ MasterType VirtualPath ="~/yourmasterpagename.master" %> You will then be able to access the property programatically from your content page like this; Master.stringproperty ......

Posted On Wednesday, February 10, 2010 10:46 AM

Copyright © PhilSando | Powered by: GeeksWithBlogs.net