Santosh 的个人资料Santosh Kumar照片日志列表更多 工具 帮助

日志


ASP.Net, Gridview paging simplified

 
Imports System
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Configuration
Imports MySql.Data.MySqlClient
 
Public Shared Sub BindGridView(ByRef faGV As GridView, ByVal faQry As String, Optional ByVal faIndex As Integer = 0)
    Dim dsPage As New DataSet
    If faIndex >= 0 Then faGV.PageIndex = faIndex
    BindDataSet(dsPage, faQry)
    faGV.DataSource = dsPage
    faGV.DataBind()
End Sub
 
Public Shared Sub BindDataSet(ByRef faDS As DataSet, ByVal faQry As String)
    Dim vMySqlConnection As MySqlConnection = Nothing
    Dim vMySqlDataAdapter As MySqlDataAdapter = Nothing
    Dim vMySqlCommand As MySqlCommand = Nothing
    Try
        vMySqlConnection = New MySqlConnection(ConfigurationManager.AppSettings("WebConfigMySql"))
        vMySqlCommand = vMySqlConnection.CreateCommand
        vMySqlCommand.CommandText = faQry
        vMySqlCommand.CommandType = CommandType.Text
        vMySqlConnection.Open()
        vMySqlDataAdapter = New MySqlDataAdapter(vMySqlCommand)
        faDS = New DataSet
        vMySqlDataAdapter.Fill(faDS)
 
    Catch ex As Exception
        faDS = Nothing
 
    Finally
        If Not vMySqlDataAdapter Is Nothing Then vMySqlDataAdapter.Dispose()
        If Not vMySqlCommand Is Nothing Then vMySqlCommand.Dispose()
        If Not vMySqlConnection Is Nothing Then vMySqlConnection.Dispose()
    End Try
End Sub
 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com
  

VB.Net, ASP.Net, Working with Cryptography

 
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Security.Cryptography
 
Public Class clsCrypto
 
    Private Shared Function GetCryptoKey() As String
        Dim vRet As String
        vRet = "jstbhgope"
        Return vRet
    End Function
 
 
    Private Shared Function GetCryptoBytes() As Byte()
        Dim vBytes() As Byte = {&H90, &H34, &H56, &H78, &H12, &HAB, &HCD, &HEF}
        Return vBytes
    End Function
 
 
    Public Shared Function DoEnCrypt(ByVal vStr As String) As String
 
        Dim vRgbKEY() As Byte = {}
        Dim vRgbIV() As Byte = GetCryptoBytes()
 
        Try
            vRgbKEY = System.Text.Encoding.UTF8.GetBytes(Left(GetCryptoKey(), 8))
 
            Dim des As New DESCryptoServiceProvider
            Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(vStr)
            Dim ms As New MemoryStream
            Dim cs As New CryptoStream(ms, des.CreateEncryptor(vRgbKEY, vRgbIV), CryptoStreamMode.Write)
            cs.Write(inputByteArray, 0, inputByteArray.Length)
            cs.FlushFinalBlock()
            Return Convert.ToBase64String(ms.ToArray())
 
        Catch ex As Exception
            Return ex.Message
 
        End Try
 
    End Function
 
 
    Public Shared Function DoDeCrypt(ByVal vStr As String) As String
        Dim vRgbKEY() As Byte = {}
        Dim vRgbIV() As Byte = GetCryptoBytes()
        Dim inputByteArray(vStr.Length) As Byte
 
        Try
            vRgbKEY = System.Text.Encoding.UTF8.GetBytes(Left(GetCryptoKey(), 8))
            Dim des As New DESCryptoServiceProvider
            inputByteArray = Convert.FromBase64String(vStr)
            Dim ms As New MemoryStream
            Dim cs As New CryptoStream(ms, des.CreateDecryptor(vRgbKEY, vRgbIV), CryptoStreamMode.Write)
 
            cs.Write(inputByteArray, 0, inputByteArray.Length)
            cs.FlushFinalBlock()
            Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
 
            Return encoding.GetString(ms.ToArray())
 
        Catch ex As Exception
            Return ex.Message
 
        End Try
 
    End Function
 
End Class
  
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com
 

VB.Net, Finding very first day number for Sun, Mon, ..., Sat of the Year

 
Public Shared Function GetVery1stDayNoOfTheYear(ByVal faDay As String, ByVal faYear As Integer) As Integer
    Dim vRet As Integer = 0
    For vRet = 1 To 7
        If UCase(Format(CDate("0" & vRet & "-Jan-" & faYear), "ddd")) = UCase(faDay) Then
            Exit For
        End If
    Next
    Return vRet
End Function 
 
Input: GetVery1stDayNoOfTheYear("SUN",2008), Output: 6
Input: GetVery1stDayNoOfTheYear("SUN",2009), Output: 4
Input: GetVery1stDayNoOfTheYear("MON",2009), Output: 5
 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com
 

ASP.Net, Designing a site visit counter module

 
There are many sites offering visit analysis for your web site including google. Once you register with them, you will get some client side script. You can put them in each of your page, and thing are over. You can try your own visit analysis module with the help of the following codes. It uses an xml file i.e. AppVisitCount.Xml, the structure is given below. All you need is to call the following functions
 
LetVisitCount(): For page load of every aspx file or master file
GetVisitCount(): To know the current visit count
GetCountBoard(): To have the following output
 
 1   5   0   8   1   9   4   7 
 
You can also write additional functions to maintain a database level logs for capturing statistics for various analysis. The function LetVisitCount() is the right place for calling your functions for such data captures.
 
'''''''''file:AppVisitCount.Xml
 
<?xml version="1.0" standalone="yes"?>
<table>
  <row>
    <hitcounter>15081947</hitcounter>
  </row>
</table>
 
'''''''''code:forVisitCount
 
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Xml
Imports System.IO
 
Private Shared Function GetVisitCount() As Long
    Dim vDs As New DataSet
    Dim vHits As Long = 0
    vDs.ReadXml(HttpContext.Current.Request.PhysicalApplicationPath & "\AppVisitCount.Xml")
    vHits = CLng(vDs.Tables(0).Rows(0).Item("hitcounter").ToString)
    Return vHits
End Function
 
Public Shared Sub LetVisitCount()
    Dim vHits As Long = 0
    If HttpContext.Current.Session("hitcounter") Is Nothing Then
        vHits = SetVisitCount()
        HttpContext.Current.Session("hitcounter") = vHits
    Else
        vHits = GetVisitCount()
    End If
End Sub
 
Public Shared Function GetCountBoard() As String
    Dim vHitsBoard As String = ""
    If Not HttpContext.Current.Session("Hits") Is Nothing Then
        Dim vHits As String = Format(CLng(HttpContext.Current.Session("hitcounter")), "0000000")
        Dim vCnt As Integer = Len(vHits)
        Dim vCtr As Integer = 0
        vHitsBoard = vHitsBoard & "<table border=1 cellpadding=1 cellspacing=0><tr>"
        For vCtr = 1 To vCnt
            vHitsBoard = vHitsBoard & "<td height=25px bgcolor='#000000' "
            vHitsBoard = vHitsBoard & "style='color:#ffffff;font-weight:bold'>"
            vHitsBoard = vHitsBoard & Mid(vHits, vCtr, 1) & "</td>"
        Next
        vHitsBoard = vHitsBoard & "</tr></table>"
    End If
    Return vHitsBoard
End Function
 
Private Shared Function SetVisitCount() As Long
    Dim vDs As New DataSet
    Dim vHits As Long = 0
    vDs.ReadXml(HttpContext.Current.Request.PhysicalApplicationPath & "\AppVisitCount.Xml")
    vHits = CLng(vDs.Tables(0).Rows(0).Item("hitcounter").ToString) + 1
    vDs.Tables(0).Rows(0).Item("hitcounter") = vHits
    vDs.WriteXml(HttpContext.Current.Request.PhysicalApplicationPath & "\AppVisitCount.Xml")
    Return vHits
End Function
 
»»»»»»»   by Santosh Kumar ?
Original @ http://santu4you.spaces.live.com
 

ASP.Net, Downloading files and images which are kept outside the web application folder

 
There are many situations where your application requires giving facilities for uploading files. If this files require sharing publically you should keep it in your web application folder so that search engines can easily search it and index then. This will also help you to ease your site search engines also. But it not a good idea to keep it inside your web application folder if you want to make it secured from unauthorized access. In such case you must keep this folder outside. But this will restrict you to use href tag from downloading. The following code will help you.
 
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.IO
 
Public Shared Function DoDownload_File(ByVal faType As String, ByVal faFile As String, ByVal faPath As String) As Boolean 
    Dim vRet As Boolean = False
    Try
        HttpContext.Current.Response.ContentType = "application/" & faType
        HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & faFile)
        HttpContext.Current.Response.TransmitFile(faPath)
        HttpContext.Current.Response.End()
        vRet = True
    Catch ex As Exception
        vRet = False
    Finally
        'doNothing
    End Try
    Return vRet
End Function
 
Public Shared Function DoDownload_Image(ByVal faFile As String, ByVal faPath As String) As Boolean 
    Dim vRet As Boolean = False
    Try
        Dim contenttype As String = "image/" & Path.GetExtension(faFile).Replace(".", "")
        Dim fs As FileStream = New FileStream(faPath & faFile, FileMode.Open, FileAccess.Read)
        Dim br As BinaryReader = New BinaryReader(fs)
        Dim bytes As Byte() = br.ReadBytes(Convert.ToInt32(fs.Length))
        br.Close()
        fs.Close()
        HttpContext.Current.Response.Buffer = True
        HttpContext.Current.Response.Charset = ""
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
        HttpContext.Current.Response.ContentType = contenttype
        HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" & faFile)
        HttpContext.Current.Response.BinaryWrite(bytes)
        HttpContext.Current.Response.Flush()
        HttpContext.Current.Response.End()
        vRet = True
    Catch ex As Exception
        vRet = False
    Finally
        'doNothing
    End Try
    Return vRet
End Function 
 
»»»»»»»   by Santosh Kumar ?
Original @ http://santu4you.spaces.live.com
 

VB.Net, Reading text from most common document formats like .txt, .doc, .xls, .pdf and web pages like (.html, .aspx, .jsp, .php .etc)

 
Reading text from different files format may give directions to most of the challenges faced for building various tools like site search engine. Once you are able to extract texts, coding of very simple logic will be sufficient to design hundreds of web and window based tools. Here in this article, I am using itextsharp.dll apart from .NET and COM libraries. 
 
You need the following binaries. iTextSharp is a free binary. All other are from Miscrosoft and should be used as per Miscrosoft guidelines. If you have MS Office installed in you system you don't need these binaries. You can simply add COM reference of MS Word and MS Excel object libraries.
  
Interop.Excel.dll for .Net 2.0
(download attachment | download from original link)
 
Interop.Word.dll for .Net 2.0
(download attachment | download from original link)
 
Interop.Office.dll for .Net 2.0
(download attachment | download from original link)
 
Interop.VBIDE.dll for .Net 2.0
(download attachment | download from original link)
 
iTextSharp for .Net 2.0
(download attachment | download from original link)
 
'''''Code Begins herefrom 
 
Imports System.IO
Imports System.Data
Imports System.Xml
Imports System.Text
Imports System.Diagnostics
Imports Microsoft.VisualBasic
Imports System.Text.RegularExpressions
Imports iTextSharp.text.pdf
Imports System.Windows.Forms
 
Public Function ReadText_TXT(ByVal faPath As String) As String
    Dim vRet As String = ""
    Dim vStreamReader As StreamReader = File.OpenText(faPath)
    Try
        vRet = vStreamReader.ReadToEnd()
        vStreamReader.Close()
    Catch ex As Exception
        vRet = ""
    End Try
    Return vRet
End Function
 
Public Function ReadText_DOC(ByVal faPath As String) As String
    Dim vRet As String = ""
    Dim vRTB As New RichTextBox
    Dim vWD As New Word.Application
    vWD.Documents.Open(faPath)
    vWD.Selection.WholeStory()
    vWD.Selection.Copy()
    vRTB.Paste()
    vRet = vRTB.Text
    vWD.Quit()
    DoGarbageCollection(vWD)
    Return vRet
End Function
 
Public Function ReadText_XLS(ByVal faPath As String) As String
    Dim vRet As String = ""
    Dim vRTB As New RichTextBox
    Dim vXL As New Excel.Application
    Dim vWB As Excel.Workbook = Nothing
    Dim vWS As Excel.Worksheet = Nothing
    Dim vUR As Excel.Range = Nothing
    Dim vCnt As Integer
    Dim vCtr As Integer
    Dim vRow As Integer
    Dim vCol As Integer
    Dim vRows As Integer
    Dim vCols As Integer
    vWB = vXL.Workbooks.Open(faPath)
    vXL.Calculation = Excel.XlCalculation.xlCalculationManual
    vXL.AlertBeforeOverwriting = False
    vCnt = vWB.Worksheets.Count
 
    For vCtr = 1 To vCnt
        vWS = vWB.Worksheets(vCtr)
        vUR = vWS.UsedRange
        vRows = vUR.Rows.Count
        vCols = vUR.Columns.Count
        For vRow = 1 To vRows
            For vCol = 1 To vCols
                vRet = vRet & CType(vUR.Cells(vRow, vCol), Excel.Range).Value & " "
            Next vCol
        Next vRow
    Next
 
    vWB.Close(False)
    DoGarbageCollection(vWB)
    vXL.Quit()
    DoGarbageCollection(vXL)
 
    Return vRet
End Function
 
Public Function ReadText_PDF(ByVal faPath As String, Optional ByVal faFromPageNum As Integer = 0, _
    Optional ByVal faUptoPageNum As Integer = 0) As String
    Dim sb As New System.Text.StringBuilder()
    Try
        Dim reader As New PdfReader(faPath)
        Dim pageBytes() As Byte = Nothing
        Dim token As PRTokeniser = Nothing
        Dim tknType As Integer = -1
        Dim tknValue As String = String.Empty
        If faFromPageNum = 0 Then
            faFromPageNum = 1
        End If
        If faUptoPageNum = 0 Then
            faUptoPageNum = reader.NumberOfPages
        End If
        If faFromPageNum > faUptoPageNum Then
            Throw New ApplicationException("Err: faFromPageNum > faUptoPageNum")
        End If
 
        For i As Integer = faFromPageNum To faUptoPageNum Step 1
            pageBytes = reader.GetPageContent(i)
            If Not IsNothing(pageBytes) Then
                token = New PRTokeniser(pageBytes)
                While token.NextToken()
                    tknType = token.TokenType()
                    tknValue = token.StringValue
                    If tknType = PRTokeniser.TK_STRING Then
                        sb.Append(token.StringValue)
                    ElseIf tknType = 1 AndAlso tknValue = "-600" Then
                        sb.Append(" ")
                    ElseIf tknType = 10 AndAlso tknValue = "TJ" Then
                        sb.Append(" ")
                    End If
                    Application.DoEvents()
                End While
            End If
        Next i
        sb = New StringBuilder(sb.ToString)
    Catch ex As Exception
        Return String.Empty
 
    End Try
    Return sb.ToString()
End Function
 
Public Function ReadText_WEB(ByVal faUrl As String) As String
    Dim vRet As String = ""
    Try
        Dim vSNWebClient As System.Net.WebClient
        Dim vUTF8Encoding As UTF8Encoding
        vSNWebClient = New System.Net.WebClient()
        vUTF8Encoding = New UTF8Encoding()
        vRet = vUTF8Encoding.GetString(vSNWebClient.DownloadData(faUrl))
    Catch ex As Exception
        vRet = ""
    End Try
    Return ReadText_HTM(vRet)
End Function
 
Private Sub DoGarbageCollection(ByVal faObj As Object)
    Try
        Runtime.InteropServices.Marshal.ReleaseComObject(faObj)
    Catch
    Finally
        faObj = Nothing
    End Try
End Sub
 
Private Function ReadText_HTM(ByVal faContent As String) As String
    Dim vRet As String = faContent
    Try
        Dim vRegEx As Regex
        vRegEx = New Regex("", RegexOptions.IgnoreCase)
        vRet = Regex.Replace(vRet, "<(select|option|script|style|title)(.*?)>((.|\n)*?)</(select|option|script|style|title)>", " ", RegexOptions.IgnoreCase)
        vRet = Regex.Replace(vRet, "&(nbsp|quot|copy);", "")
        vRet = Regex.Replace(vRet, "<([\s\S])+?>", " ", RegexOptions.IgnoreCase)
        vRet = Regex.Replace(vRet, "\W", " ")
    Catch ex As Exception
        vRet = ""
    End Try
    Return Trim(vRet)
End Function
 
»»»»»»»   by Santosh Kumar ?
Original @ http://santu4you.spaces.live.com
 

VB.Net, Working with FTP

 
FTP Transfers files to and from a computer running a File Transfer Protocol (FTP) server service such as Internet Information Services. Ftp can be used interactively or in batch mode by processing ASCII text files. The following codes illustrates how to do the related operations programatically using VB.Net environment. 
 
Imports System.IO
Imports System.Net
 
Public Function doActionFTP_GetFileList( _
    ByVal FullFtpUrl As String,
    Optional ByVal Usr As String = "", _
    Optional ByVal Pwd As String = "" _
    ) As String
    Dim vDirList As String = ""
    Try
        Dim fwreqObj As FtpWebRequest = DirectCast(WebRequest.Create(FullFtpUrl), FtpWebRequest)
        fwreqObj.Method = WebRequestMethods.Ftp.ListDirectoryDetails
        fwreqObj.Credentials = New NetworkCredential(Usr, Pwd)
        Dim fwresObj As FtpWebResponse = DirectCast(fwreqObj.GetResponse(), FtpWebResponse)
        Dim srObj As New StreamReader(fwresObj.GetResponseStream, System.Text.Encoding.ASCII)
        vDirList = srObj.ReadToEnd
 
    Catch ex As Exception
        vDirList = ""
 
    End Try
    Return vDirList
End Function
 
Public Function doActionFTP_GetFileCrDate( _
    ByVal FullFtpUrl As String, _
    Optional ByVal Usr As String = "", _
    Optional ByVal Pwd As String = "" _
    ) As Date
    Dim fcDate As Date = Now
    Try
        Dim fwreqObj As FtpWebRequest = DirectCast(WebRequest.Create(FullFtpUrl), FtpWebRequest)
        fwreqObj.Method = WebRequestMethods.Ftp.GetDateTimestamp
        fwreqObj.Credentials = New NetworkCredential(Usr, Pwd)
        Dim fwresObj As FtpWebResponse = DirectCast(fwreqObj.GetResponse(), FtpWebResponse)
        fcDate = fwresObj.LastModified
 
    Catch ex As FileNotFoundException
        fcDate = DateValue("15-AUG-1947")
 
    Catch ex As Exception
        fcDate = DateValue("26-JAN-1951")
 
    End Try
    Return fcDate
End Function
 
Public Function doActionFTP_Upload( _
    ByVal FullFilePath As String, _
    ByVal FullFtpUrl As String, _
    Optional ByVal Usr As String = "", _
    Optional ByVal Pwd As String = "" _
    ) As Boolean
    Try
        Dim fwreqObj As FtpWebRequest = DirectCast(WebRequest.Create(FullFtpUrl), FtpWebRequest)
        fwreqObj.Method = WebRequestMethods.Ftp.UploadFile
        fwreqObj.Credentials = New NetworkCredential(Usr, Pwd)
 
        Dim byteObj As Byte() = File.ReadAllBytes(FullFilePath)
        fwreqObj.ContentLength = byteObj.Length
 
        Dim sObj As Stream = fwreqObj.GetRequestStream()
        sObj.Write(byteObj, 0, byteObj.Length)
        sObj.Close()
 
        Dim fwresObj As FtpWebResponse = DirectCast(fwreqObj.GetResponse(), FtpWebResponse)
        fwresObj.Close()
    Catch ex As Exception
        vRet = False
 
    Finally
     'do nothing
 
    End Try
    Return vret
End Function
 
Public Function doActionFTP_Dnload( _
    ByVal FullFtpUrl As String, _
    ByVal FullFilePath As String, _
    Optional ByVal Usr As String = "", _
    Optional ByVal Pwd As String = "" _
    ) As Boolean
    Dim vRet As Boolean = False
    Try
        Dim fwreqObj As FtpWebRequest = DirectCast(WebRequest.Create(FullFtpUrl), FtpWebRequest)
        fwreqObj.Method = WebRequestMethods.Ftp.DownloadFile
        fwreqObj.Credentials = New NetworkCredential(Usr, Pwd)
 
        Dim fwresObj As FtpWebResponse = DirectCast(fwreqObj.GetResponse(), FtpWebResponse)
        Dim sObj As Stream = fwresObj.GetResponseStream()
 
        Dim rObj As New StreamReader(sObj)
        Dim fsObj As New FileStream(FullFilePath, FileMode.Create)
        Dim wObj As New StreamWriter(fsObj)
 
        wObj.Write(rObj.ReadToEnd)
        wObj.Flush()
        wObj.Close()
        fsObj.Close()
        rObj.Close()
        sObj.Close()
        fwresObj.Close()
        vret = True
    Catch ex As Exception
        vRet = False
 
    Finally
     'do nothing
 
    End Try
    Return vret
End Function
 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com
 

JavaScript, Browser compatibility for getElementById

 
Browser detection is one of the most common scripting task that we face. The variety of different strategies in use for detecting browsers is unlimited. Here in this article I am not going to discuss it in details. Rather I am giving the following example that will help you to identified the HTML object independent of browsers. Instead of using the method getElementById in your javascript code you use getObjectById("elementname"). Please Find the following code
 
function getObjectByID(faObj){
    if (window.document[faObj])    {
        return window.document[faObj];
    }
    if (document.embeds[faObj]){
        return document.embeds[faObj];
    }
    if (document.getElementById(faObj)){
        return document.getElementById(faObj);
    }
}
 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com
 

Asp.Net, Most useful binaries for working with .Net 2.0


Asp.Net 2.0 Ajax Extensions 1.0
(download attachment | download from original link)
 
Asp.Net Ajax enables developers to choose their preferred method of Ajax development, whether it is server-side programming, client-side programming, or a combination of both for building highly interactive and responsive web applications that work across all popular browsers. The UpdatePanels and a ScriptManager will solve all your partial post-back problems.
 
Asp.Net 2.0 Ajax Validators
(download attachment | download from original link)
 
Asp.Net 2.0 Ajax Extensions 1.0 has got some bugs while using validators. At first instant validation control will do its work but thereafter it won’t fire. Here we need the binary validators.dll. It also requires the following configurations in your web.config file.
 
<system.web>
    <pages>
    <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, 
        Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </controls>
    <tagMapping>
        <add tagType="System.Web.UI.WebControls.CompareValidator"
        mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Validators"/>
        <add tagType="System.Web.UI.WebControls.CustomValidator"
        mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Validators"/>
        <add tagType="System.Web.UI.WebControls.RangeValidator"
        mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Validators"/>
        <add tagType="System.Web.UI.WebControls.RegularExpressionValidator"
        mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Validators"/>
        <add tagType="System.Web.UI.WebControls.RequiredFieldValidator"
        mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Validators"/>
        <add tagType="System.Web.UI.WebControls.ValidationSummary"
        mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Validators"/>
    </tagMapping>
    </pages>
    ...
</system.web>
 
Asp.Net 2.0 AjaxControlToolkit
(download attachment | download from original link)
 
If you are not interested to write your own web user controls, this is where your struggle ends. Add a new tab to your toolbox and AjaxControlToolkit.dll will be included to your bin folder and then a number of Ajax control will be yours.
 
FusionCharts for Asp.Net
(download attachment | download from original link)
 
FusionCharts Enterprise Edition are really world-class solutions for web based charting solutions. It has been compatible with all the web technology and has got wider usage with PHP, ASP, .NET, JSP, ColdFusion, JavaScript, Ruby on Rails etc.
 
iTextSharp for .Net
(download attachment | download from original link)
 
It is the most useful free binary that provides most of the features you aspect for PDF files. Yes creation of PDF file from within a browser and Reading the text from the PDF file like of operations are nicely handled.
 
Winthusiasm HtmlEditor for Asp.Net 2.0
(download attachment | download from original link)
 
If you are looking for an Ajax enable HtmlEditor control then this is an answer to your search. Most of the required functionalities are covered here in this. It is much better than most of the paid version of such type of controls
 
MySql Connector for .Net 2.0
(download attachment | download from original link)
 
MySql is an answer to most of the database related challenges. From its existing MySql 5.1 onward it has been a headache for leading database solution providers. MySql.Data.dll 6.0.4 is the best solutions for your Asp.Net 2.0 applications. You can refer my article on its usage.
 
FlashControl for .Net 2.0
(download attachment | download from original link)
 
Embedding Flash / SWF object to any kind of web page is simple enough, but the challenge is to control these objects through server side scripts. FlashControl is the most useful dll to do such activity. Especially when you want to send some real-time data to flash object to set variables you will find these dll as most useful one. The property called FlashVars will be most attractive for you because you can then set multiple variables by setting values like "var1=value1&var2=value2&var3=value3" etc.

»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com 

CSS, Creating Visual Studio editor style of code-block using style-sheet in HTML code

 
A Cascading Style Sheet (CSS) contains style rules that are applied to elements in a Web page. CSS styles define how elements are displayed and where they are positioned on the page. Instead of assigning attributes to each element on your page individually, you can create a general rule that applies attributes whenever a Web browser encounters an instance of an element or an element that is assigned to a certain style class.
 
There is nothing much descriptive on the following code. It will produce the output provided to next of the code. The output not an image rather it is text formatted through the CSS. Have a look.
 
The HTML Code
 
<html>
   <head>
      <title> Santosh Kumar's Tips & Tricks </title>
      <style>
         .CssDivOut{
            margin:2px;border:1px solid #ACA899;background-color:#f8f8f8;width:100%;
            font-family:'Courier New',Courier,mono;font-size:12px;overflow:auto;max-height:400px;           
         }
         .CssDivInn{
            background:#FFF none repeat scroll 0 0;border-color:#999;border-style:none solid solid;
            border-width:medium 0px 0px;margin:0 0 0 0; overflow:auto;padding:.0 0 0 0; text-align:left;width:100%;
         }
         ol{
            list-style:decimal;list-style:decimal-leading-zero;padding:0; color:#5C5C5C;
            background-color:#fff;margin:0 0 1px 45px;
         }
         li{
            border-left:3px solid #6CE26C;margin:0; padding:0;
            padding-left:10px;white-space:nowrap;background-color:#f8f8f8;
         }
      </style>
   </HEAD>  
   <BODY>
      <div class="CssDivOut">
         <div class="CssDivInn">
            <ol>
               <li>Public Function GetFileContent(ByVal faPath As String) As String</li>
               <li>&nbsp; &nbsp; &nbsp;Dim vRet As String = ""</li>
               <li>&nbsp; &nbsp; &nbsp;Dim vStreamReader As StreamReader = File.OpenText(faPath)</li>
               <li>&nbsp; &nbsp; &nbsp;Try</li>
               <li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vRet = vStreamReader.ReadToEnd()</li>
               <li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vStreamReader.Close()</li>
               <li>&nbsp; &nbsp; &nbsp;Catch ex As Exception</li>
               <li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vRet = ""</li>
               <li>&nbsp; &nbsp; &nbsp;End Try</li>
               <li>&nbsp; &nbsp; &nbsp;Return vRet</li>
               <li>End Function</li>
            </ol>
         </div>
      </div>
   </body>
</html>
 
The HTML Output
 
  1. Public Function GetFileContent(ByVal faPath As String) As String
  2.      Dim vRet As String = ""
  3.      Dim vStreamReader As StreamReader = File.OpenText(faPath)
  4.      Try
  5.            vRet = vStreamReader.ReadToEnd()
  6.            vStreamReader.Close()
  7.      Catch ex As Exception
  8.            vRet = ""
  9.      End Try
  10.      Return vRet
  11. End Function

 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com

ASP.NET, Working with MySql 5.1 and ASP.NET 2.0 using MySqlClient – A step-by-step guidelines

 
In its official website MySql has kept a slogan i.e. ‘The world's most popular open source database’. Being experienced in both Oracle and SQL Server, I can understand what makes them to show courage to speak this. Here in this, the article aims to provide all the required related information at one place so that the journey to browser based output can become clear to .NET techies. And the article is based on the following technical specifications, have a look.
 
Operating System: Window 2000 Professional
Browser: Internet Application 6 Service Pack 1
Microsoft .NET Framework: 2.0
Web Server: IIS 5.0
Database: MySql 5.1
 
Step 1: Installation
 
Download the MySql 5.1 Connector from the link http://dev.mysql.com/downloads/connector/net/5.1.html. It will be a Windows Binaries in the shape of a zip file namely mysql-connector-net-5.1.7. Extract it somewhere and install the extracted file MySql.Data.msi. We require only a dll file i.e. MySql.Data.dll from the path <installed directory>\MySQL Connector Net 5.1.7\Binaries\.NET 2.0.
 
Step 2: Doing Prerequisites
 
I am assuming that you have already download mysql-5.1.34-win32.msi from the link http://dev.mysql.com/downloads/mysql/5.1.html#win32 and installed MySql 5.1 in your computer. Connect to ‘test’ default user and create a table called ‘emp’. And put some data inside it.
 
Step 3: Create a new project
 
Start Visual Studio 2005 and create a new website and name it something like ‘myweb’. Copy the library <installed directory>\MySQL Connector Net 5.1.7\Binaries\.NET 2.0\ MySql.Data.dll to ‘bin’ folder. Add a webpage and name it to ‘testmysql’, also set it to be default page. Put the following code in the testmysql.aspx and testmysql.aspx.vb respectively. And just run the project by pressing F5 key.
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="testmysql.aspx.vb" Inherits="testmysql" %>
 
<html>
<head runat="server">
    <title>MySql Example</title>
    <style>
        table td tr{
            font-family: Verdana; font-size: 8pt;
        }
        .mrgn_lr{
            font-family: Verdana; font-size: 8pt;
            background-color: #555555;
        }
        .mrgn_t{
            font-family: Verdana; font-size: 8pt;
            color: #ff3333;
            border-top: solid 3px #ff3333;
        }
        .mrgn_b{
            font-family: Verdana; font-size: 8pt;
            color: #ffdddd; background-color: #ff3333;
        }
        .smis{
            font-size: 8pt; background-attachment:left;
            background-image: url('app_image/xpback.gif');
            background-repeat:repeat-y;
        }
        .dcmnt{
            font-family: Verdana; font-size: 8pt;
            background-color: #ffffff;
        }
        .mnbr{
            background-color:#FFF2F2;
            border-right: #ffcaca 1px; border-top: #ffcaca 1px solid;
            border-left: #ffcaca 1px; border-bottom: #ffcaca 1px solid;
        }
    </style>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFF7F7">
    <form id="form1" runat="server">
        <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
            <tr>
                <td width="10%" class="mrgn_lr">
                </td>
                <td valign="top" style="border-right: solid 1px #ffcaca; border-left: solid 1px #ffcaca">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
                        <tr>
                            <td height="50px" class="mrgn_t" align="right">
                                <b>M Y S Q L&nbsp; &nbsp; E X A M P L E&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</b>
                            </td>
                        </tr>
                        <tr height="100%" class="dcmnt">
                            <td align="center" height="100%">
                                <asp:GridView ID="GridViewOne" runat="server" ForeColor="#555555" CellPadding=2>
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr height="21px">
                            <td class="mrgn_b" align="right">
                                Copyright not applicable&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="10%" class="mrgn_lr">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
 
 
Imports MySql.Data.MySqlClient
 
Partial Class testmysql
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        Dim vMySqlConnection As MySqlConnection = Nothing
        Dim vMySqlDataReader As MySqlDataReader = Nothing
        Dim vMySqlCommand As MySqlCommand = Nothing
        Dim vMySqlConnStr As String = Nothing
 
        Try
            vMySqlConnStr = "server=localhost; user id=root; password=root; database=test; pooling=false"
            vMySqlConnection = New MySqlConnection(vMySqlConnStr)
            vMySqlCommand = vMySqlConnection.CreateCommand
            vMySqlCommand.CommandText = "select * from emp"
 
            vMySqlConnection.Open()
            vMySqlDataReader = vMySqlCommand.ExecuteReader
            GridViewOne.DataSource = vMySqlDataReader
            GridViewOne.DataBind()
 
        Catch ex As Exception
            Throw New Exception(ex.ToString)
 
        Finally
            If Not vMySqlDataReader Is Nothing Then vMySqlDataReader.Close()
            If Not vMySqlCommand Is Nothing Then vMySqlCommand.Dispose()
            If Not vMySqlConnection Is Nothing Then vMySqlConnection.Dispose()
 
        End Try
 
    End Sub
 
End Class
 
 
  
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com

ASP.NET, Designing one of the most Generalized Navigation System using XML and Menu Control in .NET Framework 2.0

 
Microsoft has provided various ways to handle the navigations within the application. Menu Control is one amongst the best. Here in this article we are going to find a way that will handle N number of menus and its N number of navigation level with no change in the source code. The code given here is taking input from an XML file. So, let us see what is what.
 
You need to put a Menu Control and rename its ID as MenuOne. Every other bit of aspx code is written for designing purpose only. If you are interested in this design then download the small '.gif' files given below. The server side code within AddMainMenu() and AddAllSubMenus() procedures are taking care of building the entire menu. And the two importantant things I would like to discuss of data structure of XML file are (1) m01 tag and (2) common nodes.
 
The m01 tag is included for different types of menu plans. Say for example, you have 3 three category of users and their usage of menu is not same. So you can extend your menu plan to m02, m03, m04... ... ...
 
Each of the nodes contains required information about a particular menu or submenu. The mNode must contain mTxt, mVal, mUrl, and mImg. Apart from these an mNode tag can contain another mNode to built sub levels. There is nothing much to discuss about. Find the code to experiment this article.
 

 

 

xpdir.gif

xpfile.gif

xpvide.gif

xpback.gif

 
---[ ASPX ]---------------------------------------------------------------------
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mymenutest.aspx.vb" Inherits="mymenutest" %>
 
<html>
<head runat="server">
   <title>Menu Example</title>
   <style>
      td tr table{
         font-family: Verdana; font-size: 8pt;
      }
      .mrgn_lr{
         font-family: Verdana; font-size: 8pt;
         background-color: #555555;
      }
      .mrgn_t{
         font-family: Verdana; font-size: 8pt;
         color: #ff3333; border-top: solid 3px #ff3333;        
      }
      .mrgn_b{
         font-family: Verdana; font-size: 8pt;
         color: #ffdddd; background-color: #ff3333;
      }
      .smis{
         font-size: 8pt; background-image: url('app_image/xpback.gif');
         background-attachment:left; background-repeat:repeat-y;
      }
      .dcmnt{
         font-family: Verdana; font-size: 8pt;
         background-color: #ffffff;
      }
      .mnbr{
         background-color:#FFF2F2; border-right: #ffcaca 1px;
         border-top: #ffcaca 1px solid; border-left: #ffcaca 1px;
         border-bottom: #ffcaca 1px solid;
      }
   </style>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor=#FFF7F7>
   <form id="form1" runat="server">
      <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
         <tr>
            <td width="10%" class="mrgn_lr" >
            </td>
            <td valign=top style="border-right: solid 1px #ffcaca; border-left: solid 1px #ffcaca" >
               <table border="0" cellpadding="0" cellspacing="0" width=100% height=100%>
                  <tr>
                     <td height="50px" class=mrgn_t align=right>
                     <B>M E N U&nbsp; &nbsp; E X A M P L E&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</B>
                     </td>
                  </tr>
                  <tr>
                     <td align="center" >
                        <table border="0" cellpadding="0" cellspacing="0" width=100%>
                           <tr>
                              <td align="left" class=mnbr>
                                 <asp:Menu ID="MenuOne" runat="server"
                                 Orientation="Horizontal" BackColor="#FFF7F7"
                                    ForeColor="black" BorderWidth="0" BorderColor="#FFCACA"
                                    BorderStyle="Solid" DynamicMenuStyle-BorderWidth="1"
                                    DynamicMenuStyle-BorderColor="black" DynamicMenuStyle-BorderStyle="Solid"
                                    DynamicMenuStyle-CssClass="smis"
                                    StaticEnableDefaultPopOutImage="False">
                                    <StaticSelectedStyle BackColor="#FFf2f2" />
                                    <StaticHoverStyle BackColor="#990000" Font-Bold="False" ForeColor="White" />
                                    <StaticMenuItemStyle HorizontalPadding="10px" VerticalPadding="3px" />
                                    <DynamicMenuStyle BackColor="#FFF7F7" BorderColor="#FFCACA"
                                    BorderStyle="Solid" BorderWidth="1px" />
                                    <DynamicSelectedStyle />
                                    <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="3px" />
                                    <DynamicHoverStyle BackColor="#990000" Font-Bold="False" ForeColor="White" />
                                 </asp:Menu>
                              </td>
                           </tr>
                        </table>
                     </td>
                  </tr>
                  <tr height=100% class=dcmnt>
                     <td align="center" height=100%>
                     </td>
                  </tr>
                  <tr height="21px" >
                     <td class=mrgn_b align=right>
                     Copyright not applicable&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                     </td>
                  </tr>
               </table>
            </td>
            <td width="10%" class="mrgn_lr" >
            </td>
         </tr>
      </table>
   </form>
</body>
</html>
 
---[ VB ]-----------------------------------------------------------------------
 
Imports System
Imports System.IO
Imports System.Xml
Imports System.Data
 
Partial Class mymenutest
   Inherits System.Web.UI.Page
 
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      AddMainMenu("01")
   End Sub
 
   Protected Sub AddMainMenu(ByVal vMenuPlan as String)
      Dim mTxt As String
      Dim mVal As String
      Dim mUrl As String
      Dim mImg As String
 
      Dim xDoc As New XmlDocument
      xDoc.Load(Server.MapPath("~/app_data/APPMenu.xml"))
      Dim xNod As XmlNodeList = xDoc.SelectNodes("app/m" & vMenuPlan & "/mNode")
 
      Dim mCtr As Integer, mCnt As Integer
      mCnt = xNod.Count - 1
 
      MenuOne.Items.Clear()
      MenuOne.Orientation = Orientation.Horizontal
 
      For mCtr = 0 To mCnt
         mTxt = xNod(mCtr).Item("mTxt").InnerText
         mVal = xNod(mCtr).Item("mTxt").InnerText
         mUrl = xNod(mCtr).Item("mUrl").InnerText
         mImg = xNod(mCtr).Item("mImg").InnerText
 
         MenuOne.Items.Add(New MenuItem(mTxt, mVal, mImg, mUrl))
         If xNod(mCtr).SelectNodes("mNode").Count > 0 Then
            AddAllSubMenus(xNod(mCtr).SelectNodes("mNode"), MenuOne.Items(mCtr))
         End If
      Next
   End Sub
 
   Protected Sub AddAllSubMenus(ByVal xNod As XmlNodeList, ByRef mNod As MenuItem)
      Dim mTxt As String
      Dim mVal As String
      Dim mUrl As String
      Dim mImg As String
 
      Dim mCtr As Integer, mCnt As Integer
      mCnt = xNod.Count - 1
      For mCtr = 0 To mCnt
         mTxt = xNod(mCtr).Item("mTxt").InnerText
         mVal = xNod(mCtr).Item("mTxt").InnerText
         mUrl = xNod(mCtr).Item("mUrl").InnerText
         mImg = xNod(mCtr).Item("mImg").InnerText
 
         mTxt = "&nbsp;&nbsp;" & mTxt
         If mImg = "" Then mImg = "~/app_image/xpvide.gif"
 
         mNod.ChildItems.Add(New MenuItem(mTxt, mVal, mImg, mUrl))
         If xNod(mCtr).SelectNodes("mNode").Count > 0 Then
            AddAllSubMenus(xNod(mCtr).SelectNodes("mNode"), mNod.ChildItems(mCtr))
         End If
      Next
   End Sub
 
End Class
 
---[ XML ]----------------------------------------------------------------------
 
<?xml version="1.0" encoding="utf-8" ?>
<app>
      <m01>
            <mNode>
                  <mTxt>File</mTxt>
                  <mVal></mVal>
                  <mUrl></mUrl>
                  <mImg></mImg>
                  <mNode>
                        <mTxt>Search</mTxt>
                        <mVal></mVal>
                        <mUrl>http://www.live.com</mUrl>
                        <mImg></mImg>
                  </mNode>
                  <mNode>
                        <mTxt>Open</mTxt>
                        <mVal></mVal>
                        <mUrl></mUrl>
                        <mImg>~/app_image/xpdir.gif</mImg>
                  </mNode>
                  <mNode>
                        <mTxt>Save</mTxt>
                        <mVal></mVal>
                        <mUrl></mUrl>
                        <mImg>~/app_image/xpfile.gif</mImg>
                  </mNode>
                  <mNode>
                        <mTxt>Recent</mTxt>
                        <mVal></mVal>
                        <mUrl></mUrl>
                        <mImg></mImg>
                        <mNode>
                              <mTxt>File1.txt</mTxt>
                              <mVal></mVal>
                              <mUrl></mUrl>
                              <mImg></mImg>
                        </mNode>
                        <mNode>
                              <mTxt>File1.doc</mTxt>
                              <mVal></mVal>
                              <mUrl></mUrl>
                              <mImg></mImg>
                        </mNode>
                        <mNode>
                              <mTxt>File1.xls</mTxt>
                              <mVal></mVal>
                              <mUrl></mUrl>
                              <mImg></mImg>
                        </mNode>
                  </mNode>
                  <mNode>
                        <mTxt>Close</mTxt>
                        <mVal></mVal>
                        <mUrl></mUrl>
                        <mImg></mImg>
                  </mNode>
            </mNode>
            <mNode>
                  <mTxt>Edit</mTxt>
                  <mVal></mVal>
                  <mUrl></mUrl>
                  <mImg></mImg>
            </mNode>
            <mNode>
                  <mTxt>View</mTxt>
                  <mVal></mVal>
                  <mUrl></mUrl>
                  <mImg></mImg>
            </mNode>
      </m01>
</app>

»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com

Javascript, Navigating a list of URLs continuously and sequentially one by one

 
<html>
    <body>
        <script language="JavaScript">
            w=window.open('about:blank');           
            function Myfun(ctr) {
                var cnt = 10;       
                var arr = new Array(cnt);
                arr[0] = 'http://www.url_01.com';
                arr[1] = 'http://www.url_02.com';
                arr[2] = 'http://www.url_03.com';
                arr[3] = 'http://www.url_04.com';
                arr[4] = 'http://www.url_05.com';
                arr[5] = 'http://www.url_06.com';
                arr[6] = 'http://www.url_07.com';
                arr[7] = 'http://www.url_08.com';
                arr[8] = 'http://www.url_09.com';
                arr[9] = 'http://www.url_10.com';
                w.navigate("about:blank");
                w.document.write('Just a min Navigating...<br>' + arr[ctr]);
                w.navigate(arr[ctr]);
                ctr = ctr + 1;
                if (ctr == cnt) ctr = 0;
                setTimeout('Myfun(' + ctr + ')', 7000);
            }
            Myfun(0);
        </script>
    </body>
</html>
 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com

ASP.NET, How to display an image into an Image Control from an Oracle Long Row Field

 
Private Sub oracle2image(ByVal EmpId As String)
 
    'This procedure requires {Imports System.Data.Odbc}
 
    Dim vDr As OdbcDataReader
    Dim vCon As OdbcConnection
    Dim vCmd As OdbcCommand
 
    Dim PicField As Integer = 0 
    Dim dPath As String = Server.MapPath("\jpg") & "\empid.jpg"
    Dim sPath As String = Server.MapPath("\jpg") & "\frame.jpg"
    Dim vSql As String = "select empphoto from empgallery where empid = '" & EmpId & "'"
 
    Try
        vCon = dbConnect() 'This function returns an ODBC Connection object
        vCmd = vCon.CreateCommand
        vCmd.CommandText = vSql
        vCmd.CommandType = CommandType.Text
        vDr = vCmd.ExecuteReader
 
        If vDr.HasRows Then
            vDr.Read()
            Dim vByte(vDr.GetBytes(PicField, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte
            vDr.GetBytes(PicField, 0, vByte, 0, vByte.Length)
            Dim fs As New System.IO.FileStream(dPath, IO.FileMode.Create, IO.FileAccess.Write)
            fs.Write(vByte, 0, vByte.Length)
            fs.Close()
 
        Else
            IO.File.Copy(sPath, dPath, True)
 
        End If
 
        imgPhoto.ImageUrl = "jpg/empid.jpg"
 
    Catch ex As Exception
        Throw ex
 
    Finally
        If Not vDr Is Nothing Then vDr.Close()
        If Not vCmd Is Nothing Then vDr.Dispose()
        If Not vCon Is Nothing Then vCon.Close()
 
    End Try
 
End Sub

 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com

IIS, Version details on different windows operating system

 
IIS 1.0, Windows NT 3.51 available as a free add-on
IIS 2.0, Windows NT 4.0
IIS 3.0, Windows NT 4.0 Service Pack 3
IIS 4.0, Windows NT 4.0 Option Pack
IIS 5.0, Windows 2000
IIS 5.1, Windows XP Professional, Windows XP Media Center Edition
IIS 6.0, Windows Server 2003 and Windows XP Professional x64 Edition
IIS 7.0, Windows Server 2008 and Windows Vista (Business, Enterprise, Ultimate Editions)
IIS 7.5, Windows Server 2008 R2 (Beta) and Windows 7 (Beta)

IIS 6.0, It is not possible to run two different versions of ASP.NET in the same IIS process.

 
Windows 2003 uses IIS 6.0 and it takes DefaultAppPool for all the websites by default. If you try to run two different versions of ASP.NET e.g. Frameworks 1.1 and 2.0 then you will get the following errors
 
“...It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process...”
 
To come out of this problem, verify all required versions of the framework installed is registered or not, if not, register them. Create additional application pool and set it accordingly. If you have created two application pools i.e. AP1 and AP2 then set AP1 for all .NET 1.1 web applications and AP2 for all .NET 2.0 web applications. Try the following procedures.
 
...1. Register the required framework.
 
Even though it is installed, it may not have registered.
Open IIS 6.0 -> ASP.NET.
Check the list on Combobox to the right of ASP.NET version.
 
If frameworks 1.1 is not listed in the combobox, do this,
Win 2K, cd %windir%\microsoft.net\framework\v1.1.4322\ aspnet_regiis.exe -i
Win 3K, cd %windir%\microsoft.net\framework\v1.1.4322\ aspnet_regiis.exe –i -enable
Win XP, cd %windir%\microsoft.net\framework\v1.1.4322\ aspnet_regiis.exe –i
 
If frameworks 2.0 is not listed in the combobox, do this,
Win 2K, cd %windir%\microsoft.net\framework\v2.0.50727\ aspnet_regiis.exe -i
Win 3K, cd %windir%\microsoft.net\framework\v2.0.50727\ aspnet_regiis.exe –i -enable
Win XP, cd %windir%\microsoft.net\framework\v2.0.50727\ aspnet_regiis.exe –i
 
...2. Set .NET 1.1 as default for default_web_sites
 
Expand internet_information_services -> {local_computer} -> default_web_sites.
Right click default_web_sites -> properties.
Go to ASP.NET tab and set the version as 1.1.4322.
 
...3. Keep all .NET application folders in a separate drive or folder and configure it.
 
Don’t keep it in default home directory i.e. c:\inetpub\wwwroot.
Change the default page so that to redirect accordingly
{refer the article How to maintain single server to support multiple URLs}
 
...4. Create application pool and set it.
 
Open IIS Manager
Expand internet_information_services -> {local_computer} -> application_pools.
Right click application_pools -> new -> application_pool.
Specify application_pool_id e.g. APP_POOL_1.1, Click OK.
Repeat the process and create one more i.e. APP_POOL_2.0.
 
...5. Set the proper ASP.NET version.
 
Open IIS Manager
Expand internet_information_services -> {local_computer} -> default_web_sites.
Right click your .NET 1.1 applications -> properties.
Go to ASP.NET tab and set the version as 1.1.4322.
Do the above process for all .NET 1.1 web applications.
Accordingly do it for all .NET 2.0 web applications.
 
...6. That’s all... Best of luck!!!
 
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com 

IIS 6.0, How to maintain single server to support multiple URLs

 
There can be a number of ways to support multiple URLs in a single server. The one I am going to discuss in this article is to use javascript. Just go through the following steps.
 
...1. Find out default web site’s home directory
 
Click start_button -> settings -> control_panel
Open administrative_tools - > internet_services_manager
Expand internet_services_manager -> {server_name} -> default_web_site
Right click default_web_site -> properties -> home_directory -> local_path
Normally it is c:\inetpub\wwwroot
 
...2. Create an html file in this home directory and give some name to it, say default.html.
 
...3. Put code in that html file using following template. Change “about.company.com”, “product.company.com” as per your URLs. 
 
<html>
    <head>
        <title>My Title</title>
        <script language = javascript>
            var whois = location + " ";
            if (whois.indexOf("about.company.com") != -1){
                window.location = "virdir1";
            }
            else if (whois.indexOf("product.company.com") != -1){
                window.location = "virdir2";
            }
            else {
                window.location = "virdir0";
            }
        </script>
    </head>
    <body>My Company</body>
</html>
 
...4. All of “virdir0”, “virdir1”, “virdir2” are virtual directories under the  default web site of IIS. Create them.
 
...5. Remove all and add default.html to documents tab of default_web_sites_properties window.
 
...6. That’s all... Best of luck!!!
  
»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com 

ASP.NET, Handling all Oracle DML with a generalized method

When it needs to insert, update or delete records from oracle table, the best practice is to use precompiled store procedures. But to call these store procedure programmers are writing a bunch of codes. The following code in ASP.NET using VB.NET will solve your maximum issues
 
Public Shared Function ExecuteOraSP(ByVal myOraSP As String, ByVal myOraPrmIP As String, ByVal myOraValIP As String, ByVal myOraTypIP As String) As Integer
 
    '''''common'procedure'for'insert'delete'and'upadte'using'oracle'procedure'''''
    'Returns Err(-1), Success(>=0)
 
    '''''Sample oracle procedure looks like this...
    'CREATE OR REPLACE PROCEDURE SP_EMP_U(
    '    vID Number:=0,
    '    vNAME Varchar2:=null,
    '    OraReturn out Number) AS
    'BEGIN
    '    OraReturn:=-1;
    '    update emp set ename=vNAME where empno=vID;
    '    OraReturn:= SQL%ROWCOUNT ;
    'END;
    '/
 
    '''''how to call
    'Dim myOraSP As String = "SP_EMP_U"
    'Dim myOraPrmIP As String = "vID" & getPipe() & "vNAME"
    'Dim myOraValIP As String = "7369" & getPipe() & "RPS"
    'Dim myOraTypIP As String = "N" & getPipe() & "VC"
 
    Dim myOraPrmOP As String = "OraReturn"
 
    Dim myExecuteFeedback As Integer = 0
 
    Dim myOracleConnection As OracleConnection = Nothing
    Dim myOracleDataReader As OracleDataReader = Nothing
    Dim myOracleCommand As OracleCommand = Nothing
 
    Dim myOracleParameterIP As OracleParameter
    Dim myOracleParameterOP As OracleParameter
 
    Dim myArrPrm() As String = Split(myOraPrmIP, getPipe())
    Dim myArrVal() As String = Split(myOraValIP, getPipe())
    Dim myArrTyp() As String = Split(myOraTypIP, getPipe())
 
    If myArrPrm.Length <> myArrVal.Length _
    And myArrPrm.Length <> myArrTyp.Length _
    Then Return myExecuteFeedback
 
    Dim vCnt As Integer = myArrPrm.Length - 1
    Dim vCtr As Integer = 0
    Dim myOracleType As OracleType = 0
 
    Try
        myOracleConnection = New OracleConnection(getOracleConnectionString())
        myOracleCommand = myOracleConnection.CreateCommand
        myOracleCommand.CommandText = myOraSP
        myOracleCommand.CommandType = CommandType.StoredProcedure
        myOracleConnection.Open()
 
        'adding ipput parameter
        For vCtr = 0 To vCnt
            If myArrTyp(vCtr) = "VC" Then myOracleType = OracleType.VarChar
            If myArrTyp(vCtr) = "DT" Then myOracleType = OracleType.DateTime
            If myArrTyp(vCtr) = "CH" Then myOracleType = OracleType.Char
            If myArrTyp(vCtr) = "N" Then myOracleType = OracleType.Number
            If myArrTyp(vCtr) = "B" Then myOracleType = OracleType.Byte
            If myArrTyp(vCtr) = "D" Then myOracleType = OracleType.Double
            If myArrTyp(vCtr) = "F" Then myOracleType = OracleType.Float
            myOracleParameterIP = myOracleCommand.Parameters.Add(myArrPrm(vCtr), myOracleType)
            myOracleParameterIP.Direction = ParameterDirection.Input
            myOracleParameterIP.Value = myArrVal(vCtr)
        Next
 
        'adding output parameter
        myOracleParameterOP = myOracleCommand.Parameters.Add(myOraPrmOP, OracleType.Number)
        myOracleParameterOP.Direction = ParameterDirection.Output
 
        'executing
        myOracleDataReader = myOracleCommand.ExecuteReader
 
        'getting feedback
        myExecuteFeedback = myOracleParameterOP.Value
 
 
    Catch ex As Exception
        myExecuteFeedback = -1
 
    Finally
        If Not myOracleDataReader Is Nothing Then myOracleDataReader.Close()
        If Not myOracleCommand Is Nothing Then myOracleCommand.Dispose()
        If Not myOracleConnection Is Nothing Then myOracleConnection.Dispose()
    End Try
 
    Return myExecuteFeedback
 
End Function
 
Public Shared Function getPipe() As String
    Return Chr(1) & Chr(2) & Chr(3)
End Function
 
»»»»»»»   by Santosh Kumar
 ?
Original @ http://santu4you.spaces.live.com

ASP.NET, Page validation techniques

Role based application, generally go for thousand lines of coding in each page. This is for validation of the menus and links. And also for the validation of access to those pages, which are directly specified on the address bar having been logged in. Doing a lot of database access for each page just for validation is not a good practice, specially when there exit hundreds of hits per minute.
 
Following code illustrates how just calling a function called “doAuthentication” can validate a page. The menu system can be arranged by xml based coding. Each of the clicks to the link must maintain dynamic coding that will store the URL of the page in a session variable before it redirects to that page.
 
Public Shared Sub doAuthentication(ByVal IsPostbackFlag As Boolean)
    ''''check for login
    If HttpContext.Current.Session("objUser") Is Nothing Then
        HttpContext.Current.Response.Redirect("login.aspx")
    End If
    ''''check for authorised pages
    If Not IsPostbackFlag Then
        Dim thisUrl As String = HttpContext.Current.Request.FilePath.ToString()
        Dim vArrURL() As String = Split(thisUrl, "/")
        Dim thisPage As String = LCase(vArrURL(vArrURL.Length - 1))
        Dim objUser As clsUser = HttpContext.Current.Session("objUser")
        If LCase(objUser.UserURL) <> LCase(thisPage) Then
            HttpContext.Current.Response.Redirect("app__access_denied.aspx")
        End If
    End If
End Sub
 
»»»»»»»   by Santosh Kumar
 ?
Original @ http://santu4you.spaces.live.com

ASP.NET, Quickly web deployment in 2005

There exists many methods for deploying ASP.NET 2.0 projects. And I prefer doing it through ASPNET_COMPILER. Let us assume your project is  created at D:\MYPRJ\MYWEB and the virtual directory refering it is MYURL. Now use the following batch file for getting the output at D:\DEPLOY. That's all
 
 
@ECHO OFF
ECHO.
 
ECHO ASP 2.0 COMPILATION PROGRAM
ECHO AUTHORED BY SANTOSH KUMAR
ECHO ====================================
ECHO.
ECHO Started...!!!
ECHO.
 
ECHO Changing drive to windows drive
%SYSTEMDRIVE%
ECHO Done...!!!
ECHO.
 
ECHO Changing directory to ASP 2.0 framework directory
CD  %WINDIR%\MICROSOFT.NET\FRAMEWORK\V2.0.50727
ECHO Done...!!!
ECHO.
 
ECHO Removing existing folders and files
RD /S /Q D:\DEPLOY
ECHO Done...!!!
ECHO.
 
ECHO Creating D:\DEPLOY
MD D:\DEPLOY
ECHO Done...!!!
ECHO.
 
ECHO Stating compilation
ASPNET_COMPILER -v /"MYURL" -p "D:\MYPRJ\MYWEB" -u "D:\DEPLOY"
ECHO Done...!!!
ECHO.
 
PAUSE
 
 
Oh yes! you must have necessary prerequisites on your target server and you can follow the following order to install them
2.0 _step1 Microsoft .NET Framework Version 2.0 Redistributable Package {dotnetfx}
2.0 _step2 Microsoft .NET Framework SDK Version 2.0 {setup.exe}
2.0 _step3 Security Update for Windows 2000 {Windows2000-KB835732-x86-ENU}
2.0 _step4 Update Rollup 1 for SP4 {Windows2000-KB891861-v2-x86-ENU}
2.0 _step5 Microsoft .NET Framework 2.0 Service Pack 1 {NetFx20SP1_x86}
2.0 _step6 Microsoft ASP.NET 2.0 AJAX Extensions 1.0 {ASPAJAXExtSetup}

»»»»»»»   by Santosh Kumar ? Original @ http://santu4you.spaces.live.com