0

Read a Web Page and send it as an HTML Email

Recently I was asked to write a code to send entire Aspx page as an HTML mail using VB.Net.
Private Function ReadAspxPage(ByVal url As String) As String
Dim htmlPage As String
Dim objResponse As System.Net.WebResponse
Dim objRequest As System.Net.WebRequest = System.Net.HttpWebRequest.Create(url)
objResponse = objRequest.GetResponse()
Dim readpage As New System.IO.StreamReader(objResponse.GetResponseStream())

htmlPage = readpage.ReadToEnd()
readpage.Close()

Return htmlPage.toString()
End Function

0

How to read HTML file onServer in ASP.Net

Private Function GetEmailTemplate(ByVal templateName As String) As String
Dim sr As IO.StreamReader = New IO.StreamReader(System.Web.HttpContext.Current.Server.MapPath(templateName))
Dim body As String = sr.ReadToEnd()
sr.Close()
sr.Dispose()
Return body
End Function

0

Read all Mail Merge Field in an Collection.

I was asked to read all Mail merge Files in an HTML Template and then perform a mail Merge.
The MailMerge Fields were like ##[Field]##.
So thought to use regex to find the fields.

The biggest task for me was to write a regex for Matching ##[Merge Fields]##.

0

How to Use Code Behind to display text on Binding

I had to display Yes or No based on databind this is how I did it.

<asp:Label ID=”IsUserActiveCheckBox” Text=’<%# if(Eval(“IsUserActive”),”Yes”,”No”) %>’
runat=”server” />

Also Bind will not work if you are databinding it.

Here is another example where I used code behind.

in Aspx :

<asp:RadioButtonList ID=”rbGLRSearch” runat=”server” RepeatDirection=”Horizontal”
OnSelectedIndexChanged=”EnableCluster” AutoPostBack=”true” SelectedValue=’<%# GetCheckBoxValue(Eval(“GLRSearch”)) %>’>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
<asp:ListItem>N/A</asp:ListItem>
</asp:RadioButtonList>

in code behind :

Protected Function GetCheckBoxValue(ByVal bool) As String

If bool Is Nothing Then
Return “N/A”
ElseIf bool = True Then
Return “Yes”
ElseIf bool = False Then
Return “No”
End If
Return True
End Function

0

Some Top Must-Have Tools for an ASP.NET Developer

Came across this blogs.

really good collection of tools.

worth trying them.

http://www.dotnetcurry.com/(X(1)S(ksuw3045ka04q3rcittjc0nk))/ShowArticle.aspx?ID=103&AspxAutoDetectCookieSupport=1

0

Performance Tips for ASP.NET Applications

I found this article while looking for improving the performance of ASP.NET for one of my application.

Its really good one.

I am going to try some of the stuff and see if there is a difference in performance.

Here;s the link to the blog

http://blogs.microsoft.co.il/blogs/rotemb/archive/2008/08/17/performance-tips-for-asp-net-applications.aspx

http://blogs.microsoft.co.il/blogs/rotemb/archive/2008/07/29/tune-your-net-application-that-suffer-from-contention-poor-performance-and-deadlocks.aspx