Archive for July 18, 2006

Maintaining the Scroll Position after post back

Some of us may come across this situation, ie maintaining the scroll position after the page is post back. This is very useful when we have a gridview or data repeater or some thing like that, which shows a large amount of data and a button controls is place below page, so that user has to scroll a bit to reach there. After clicking on the button, the page is posted back, but the page is scrolled to top.

If you want to maintain the scroll position, add this attribute on the @page directive

<%@ Page Language=”VB” MaintainScrollPositionOnPostback=”true”

Hope this will help you

Advertisements

July 18, 2006 at 12:09 pm 9 comments

Sending Emails from ASP.NET 2.0

SendingĀ  Emails from ASP.NET is very easy. In .NET 1.1 and 1.0, the class was System.Web.Mail but in .NET 2.0, they changed to System.Net.Mail.

The code for sending anĀ  email is given below

VB.NET

Dim email As MailMessage
Dim mailClient As SmtpClient

email = New MailMessage(fromAdd, toAdd, subject, message)

‘if you want to send HTML message set this property to true
email.IsBodyHtml = True

mailClient = New SmtpClient(“Your mail server name”) ‘like mail.xxx.com

‘ if your server is using different port then set this
mailClient.Port = [PortNumber]

mailClient.Send(email)

Some times your outgoing SMTP server may need username and password. Then you need to modify the code little bit.

First create an object of NetworkCredential (This is available in the System.Net Namespace) with the username and password

Dim authInfo As New NetworkCredential(smtpUsername, smtpPassword)

Then set the UseDefaultCredentials property of the smtp client object to false and set the Credentials property of the smtp client object to authInfo. Then send the mail.

mailClient.UseDefaultCredentials = False
mailClient.Credentials = authInfo

July 18, 2006 at 5:54 am 1 comment


Top Clicks

  • None

Calendar

July 2006
M T W T F S S
    Aug »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Recent Posts

Feeds

Blog Stats

  • 93,152 hits