Make Previous Calendar Dates not Selectable

In order to make all dates before the current date, not able to be selected, in the onDayRender event for your Calendar:

If (Args.Day.Date < DateTime.Today) Then Args.Day.IsSelectable = False End If

To make it more obvious to the end user, also add:

Args.Cell.BackColor = Drawing.Color.GhostWhite Args.Cell.ForeColor = Drawing.Color.Gainsboro

Thanks to the idea from Peter Blum

Avoid Javascript Errors

It is sometime unavoidable to get rid of javascript errors. To get rid of it just go through following code.

<head>
<script language="javascript">
function stoperror()
{
  return true
}
window.onerror=stoperror
</script>
</head>


DotNetGuts (DNG)
Logon to http://www.DotNetGuts.Blogspot.com

Keeping DataTable in Viewstate

In order to persist a datatable, you can easily add it to the Viewstate, by creating a property in your class:
What I do in many circumstances, is, like the last post said, pass the DataTable to viewstate as a property of the class:

Private Property EmployeeData() As System.Data.DataTable
        Get
            Dim o As Object = ViewState("EmployeeData")
            If o Is Nothing Then
                Return Nothing
            Else
                Return o
            End If
        End Get
        Set(ByVal value As System.Data.DataTable)
            ViewState("EmployeeData") = value
        End Set
    End Property

Now, whenever you need to repopulate, or add a row, remove a row, etc – just refer to the property “EmployeeData”

Global Popup Message routine

If you have popup messages in multiple places in your website, you can create one global routine, so that you can build them dynamically, wherever you want in the site, with whatever message you need. Just create a separate class (or add to an existing class in your app_code folder) and put this code in it:

Public Sub DisplayMessage(ByVal webPage As Object, ByVal Message As String) Dim msgDisplay As String = "alert('" & Replace(Message, "'", "\'") & "');" webPage.ClientScript.RegisterStartupScript(Me.GetType, "DisplayMessage", msgDisplay) End Sub

To use it, just put something like this, in your code:
DisplayMessage(me,”YourMessageGoesHere”)
That’s all there is to it!