ASP.Net KnowledgeBase Menu

 

ToolBar Code

ToolBar2 Code

ASPNet 2005

MS Data Access Blocks

Graphics

Functions And Subs Module

Creating And Using Objects Article

Encrypt Query String
Streams Explained

Email

 

Custom Web Control Creation

 

SQLServer Notes

 

Minimum Folder Security Settings

Functions & Subs

FileInfo And DirectoryInfo Class

DataGrid

DataList

DropDownList

JavaScript

html

Calendar

ListBox

Web Service

 

WebChart Control (keywords: Graph Bar Chart)

PanelBar 3.0 & WebMenu 2.0 Samples

 

 

ServerHtmlEncode To Prevent Scripting Attacks…

My Send/Receive WebService

 

 

 

How to make a button the Defualt Button on-enter-key:

'Make the Lookup Button fire when "ENTER" is hit... **********

        Page.RegisterHiddenField("__EVENTTARGET", cmdLookup.ClientID)

        '*************************************************************

 

The reason for this (besides occasional mis-designed SQL statement) is, that not all necessary permissions are set. User IUSR_<machine name> has to have permissions:

  1. for the directory the Access database resides in (right-click on the directory in Explorer, select "Properties," "Security", if the "Security" Tab is missing, go into "Tools," "Folder Options," and deactivate "Simple File sharing")
  2. for the Access database itself ("Tools", "Security", "User and Group Permissions")

 

How To Disable A Button After The User Clicks It So It Is Not Clicked Twice

 

The Solution In your Page_Load function, inject some client side code by adding an onlclick attribute to your button control. My example below does three things, it changes the text of the button, disables it, then causes a postback to fire. The reason for the last step, is that once you disable the button, you can no longer submit the form in the normal way. I've used the GetPostBackEventReference method to ensure that the __doPostBack client side function is included on the page.

 

Public Class WebForm1

    Inherits System.Web.UI.Page

 

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Put user code to initialize the page here

        Button1.Attributes.Add("onclick", "Button1.value='Please wait...';Button1.disabled = true;" +    GetPostBackEventReference(Button1))

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        System.Threading.Thread.Sleep(2000)

        Label1.Text = DateTime.Now.ToString()

    End Sub

End Class

 

 

 

Validate the session…

 

    Function ValidSession() As Boolean

 

        If Session.IsNewSession = False Then

            'Getting into this "If" statement means that we arrived at this page with a

            'session already created for us.

 

            If Request.UrlReferrer() Is Nothing Then

                'This scenario represents a user typing into his address bar the our url with a

                'sesion id from a previous session...

                Return False

            Else

                'This scenario represents a link from another web site with a

                'session id, (from a previous session), embedded in the link...

                Dim sReferringURL As String = Request.UrlReferrer.ToString

                Dim sCurrentUrl As String = Request.Url.ToString

                Dim iParen = InStr(sReferringURL, "(")

                'If iParen > 0 then the referring url could possible have a session id embedded in it...

                If iParen > 0 Then

                    'Check to see if the Referrer is a page from our web site...

                    If Mid(sReferringURL, 1, iParen - 1) <> Mid(sCurrentUrl, 1, iParen - 1) Then

                        Return False

                    End If

                End If 'iParen > 0

            End If 'Request.UrlReferrer() Is Nothing

        End If 'IsNewSession = False

 

        ValidSession = True

 

    End Function