Opening an alert from codebehind

Page.RegisterStartupScript("startup", "<script>alert('Nothing selected to perform selected operation.');</script>");

Like

We will use the Customers table to illustrate the SQL LIKE clause usage:

FirstName LastName Email DOB Phone
John Smith John.Smith@yahoo.com 2/4/1968 626 222-2222
Steven Goldfish goldfish@fishhere.net 4/4/1974 323 455-4545
Paula Brown pb@herowndomain.org 5/24/1978 416 323-3232
James Smith jim@supergig.co.uk 20/10/1980 416 323-8888
The SQL LIKE clause is very useful when you want to specify a search condition within your SQL WHERE clause, based on a part of a column contents. For example if you want to select all customers having FirstName starting with 'J' you need to use the following SQL statement:


SELECT *
FROM Customers
WHERE FirstName LIKE 'J%'

Here is the result of the SQL statement above:

FirstName LastName Email DOB Phone
John Smith John.Smith@yahoo.com 2/4/1968 626 222-2222
James Smith jim@supergig.co.uk 20/10/1980 416 323-8888
If you want to select all Customers with phone numbers starting with '416' you will use this SQL expression:


SELECT *
FROM Customers
WHERE Phone LIKE '416%'

The '%' is a so called wildcard character and represents any string in our pattern.
You can put the wildcard anywhere in the string following the SQL LIKE clause and you can put as many wildcards as you like too.
Note that different databases use different characters as wildcard characters, for example '%' is a wildcard character for MS SQL Server representing any string, and '*' is the corresponding wildcard character used in MS Access.
Another wildcard character is '_' representing any single character.
The '[]' specifies a range of characters. Have a look at the following SQL statement:


SELECT *
FROM Customers
WHERE Phone LIKE '[4-6]_6%'

This SQL expression will return all customers satisfying the following conditions:

  • The Phone column starts with a digit between 4 and 6 ([4-6])
  • Second character in the Phone column can be anything (_)
  • The third character in the Phone column is 6 (6)
  • The remainder of the Phone column can be any character string (%)
Here is the result of this SQL expression:
FirstName LastName Email DOB Phone
John Smith John.Smith@yahoo.com 2/4/1968 626 222-2222
Paula Brown pb@herowndomain.org 5/24/1978 416 323-3232
James Smith jim@supergig.co.uk 20/10/1980 416 323-8888

Finding the sum of all the value of a column.

Select  Sum(cast (m.FileSize as BigInt))
from Documents m

Documents->table name
FileSize->Column name

Setting the value dynamically

 ASPX
--------------------------------

<table width="100%" style="background-color:#336699;">
 <tr>
        <td style="background-color: #4791c5;width:100%;padding-right:50px"  colspan="3" align="right">
            <%--<asp:Label ID="lblCompanyName" runat="server" Font-Names="Verdana" Font-Size="X-Small"
                Visible="False" Font-Bold="false" ForeColor="White"></asp:Label>--%>
                <%= AccountandHelpLink %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="../../support.html"></a><a href="../../support.html"></a><a href="../../contact.html">
            </a><a href="../../contact.html"></a>
            <%= LogoffLink %>
        </td>
        <%--<td align="center" style="background-color: #4791c5;">
             <
        </td>--%>
    </tr>
</table>

C#
-------------------

LogoffLink = ControlChars.Cr & "<" & "a href='" & Request.ApplicationPath & "/Admin/Logoff.aspx'  ><FONT face='Verdana' font-family='Arial' size='1' color='ffffff'>" & "     SignOut<" & "/a>"


 AccountandHelpLink = "<" & "FONT face='Verdana' color='#ffffff' size='1'" & ">" & accLink & sUserId & "&username=" & sUserName & ">" & "<" & "FONT face='Verdana' color='#ffffff' size='1'" & ">" & "My Account" & "</FONT>" & "</a>&nbsp;&nbsp;" & "<span class='Accent'>|</span>" & "&nbsp;&nbsp;" & _
                    "<a href=" & sHelpfileLocation & " target='_new'>" & "<" & "FONT face='Verdana' color='#ffffff' size='1'" & ">" & "Help" & "</FONT>" & "</a>&nbsp;&nbsp;</FONT>&nbsp;"
             



Remember login using Cookies

CreateCookies()
--------------------------------------------------------------------------

Public Sub CreateCookies()
            'check if remember me checkbox is checked on login
            If (Me.RememberCheckbox.Checked) Then
                'Check if the browser support cookies
                If (Request.Browser.Cookies) Then
                    'Check if the cookie with name PBLOGIN exist on user's machine
                    If (Request.Cookies("PBLOGIN") Is Nothing) Then
                        'Create a cookie with expiry of 30 days
                        Dim uidPwd As HttpCookie = New HttpCookie("PBLOGIN")

                        uidPwd("UserName") = Me.email.Text
                        uidPwd("Pwd") = Me.password.Text
                        uidPwd.Expires = DateTime.Now.AddDays(5)
                        Response.Cookies.Add(uidPwd)

                        Dim x As String = Request.Cookies("PBLOGIN")("UserName").ToString()

                        Dim y As String = Request.Cookies("PBLOGIN")("Pwd").ToString()

                        'Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(30)
                        ''Write username to the cookie
                        'Response.Cookies("PBLOGIN").Item("UNAME") = Me.email.Text
                        ''Write password to the cookie
                        'Response.Cookies("PBLOGIN").Item("UPASS") = Me.password.Text
                        ''If the cookie already exist then wirte the user name and password on the cookie
                        'Else
                        '    Response.Cookies("PBLOGIN").Item("UNAME") = Me.email.Text
                        '    Response.Cookies("PBLOGIN").Item("UPASS") = Me.password.Text
                    End If
                End If
            End If
        End Sub

---------------------------------------------------------------

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not IsPostBack() Then
                               CheckCookies()
            End If
        End Sub
-------------------------------------------------------------------------------


Public Sub CheckCookies()

            'Check if the browser support cookies
            If Request.Browser.Cookies Then
                'Check if the cookies with name PBLOGIN exist on user's machine
                If Request.Cookies("PBLOGIN") IsNot Nothing Then
                    'Pass the user name and password to the VerifyLogin method
                    Me.VerifyLogin(Request.Cookies("PBLOGIN")("UserName").ToString(), Request.Cookies("PBLOGIN")("Pwd").ToString())
                End If

            End If
        End Sub



------------------------------------------------------------------------------------------


Protected Sub VerifyLogin(ByVal UserName As String, ByVal Password As String)
            Try
                Me.email.Text = UserName
                Me.password.Text = Password

            Catch ex As System.Exception
                Response.Write(ex.Message)
            End Try
        End Sub


Page Events in VB

  Protected Sub page_preInit(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Response.Write("Page preInit")
    End Sub

    Protected Sub page_init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Init
        Response.Write("Page init")
    End Sub


Protected Sub page_initComplete(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.InitComplete
        Response.Write("Page InitComplete")
    End Sub

   Protected Sub page_pagePreLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.PreLoad
        Response.Write("Page PreLoad")
    End Sub

Protected Sub page_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

  Protected Sub page_pageLoadComplete(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
        Response.Write("Page LoadComplete")
    End Sub


  Protected Sub page_pagePreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Response.Write("Page PreRender")
    End Sub

Protected Sub page_pagePreRenderComplete(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
        Response.Write("Page PreRenderComplete")
    End Sub


Protected Sub page_pageSaveStateComplete(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.SaveStateComplete
        Response.Write("Page SaveStateComplete")
    End Sub






  
   
    Protected Sub page_pageDisposed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Disposed
        Response.Write("Page Disposed")

    End Sub
    Protected Sub page_pageError(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Error
        Response.Write("Page Error")
    End Sub
 
 
    'Protected Sub page_pageUnload(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Unload
    '    Response.Write("Page Unload")
    'End Sub