Wednesday, December 31, 2008

Manage View State In Session

'Manage View state in Session

    Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)

 

        Dim VSKey As String

        'String that will hold the Unique Key

        'used to reference this ViewState data

 

        'Create the key based on the SessionID, on the Request.RawUrl

        'and on the Ticks representated by the exact time

        'while the page is being saved

 

        If Request.Form("__VIEWSTATE_KEY") Is Nothing Then

            VSKey = "VIEWSTATE_" & MyBase.Session.SessionID & "_" & _

                            Request.RawUrl & "_" & Date.Now.Ticks.ToString

        Else

            VSKey = Request.Form("__VIEWSTATE_KEY")

        End If

 

        'Store the viewstate in the Session.

        Session(VSKey) = viewState

 

        'Register a HiddenField on the Page,

        'that contains ONLY the UniqueKey generated.

        'With this, we'll be able to find with ViewState

        'is from this page, by retrieving these value.

        ClientScript.RegisterHiddenField("__VIEWSTATE_KEY", VSKey)

 

    End Sub

 

    Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object

 

        Dim VSKey As String 'ViewState UniqueKey

        VSKey = Request.Form("__VIEWSTATE_KEY")

        'Request the Key from the page and validade it.

 

        If Not VSKey.StartsWith("VIEWSTATE_") Then

            Throw New Exception("Invalid VIEWSTATE Key: " & VSKey)

        End If

 

        Return Session(VSKey)

 

    End Function

Monday, December 29, 2008

Window And Element Viewport Size (Width and Height) With Java-script

<script type="text/javascript">
 var viewportwidth;
 var viewportheight;

/*the more standards compliant browsers (mozilla/netscape/opera/IE7)
use window.innerWidth and window.innerHeight*/
 if (typeof window.innerWidth != 'undefined')
 {
 viewportwidth = window.innerWidth,
 viewportheight = window.innerHeight
 }
/*IE6 in standards compliant mode
(i.e. with a valid doctype as the first line in the document)*/
 else if (typeof document.documentElement != 'undefined'
 && typeof document.documentElement.clientWidth !=
 'undefined' && document.documentElement.clientWidth != 0)
 {
 viewportwidth = document.documentElement.clientWidth,
 viewportheight = document.documentElement.clientHeight
 }
// older versions of IE
 else
 {
 viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
 viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }

function getElementWith(el)
{
 if (el){
/*the more standards compliant browsers (mozilla/netscape/opera/IE7)
use window.innerWidth and window.innerHeight*/
  if (typeof el.innerWidth != 'undefined')
  {
  return el.innerWidth
  }
/*IE6 in standards compliant mode
(i.e. with a valid doctype as the first line in the document)*/
  else if (typeof el != 'undefined'
  && typeof el.clientWidth !=
  'undefined' && el.clientWidth != 0)
  {
  return el.clientWidth
  }
// older versions of IE
  else
  {
  return el.clientWidth
  }
 }
}
</script>

Sunday, December 28, 2008

Fibonacci Numbers

In mathematics, the Fibonacci numbers are a sequence of numbers named after Leonardo of Pisa, known as Fibonacci (a contraction of filius Bonaccio, "son of Bonaccio"). Fibonacci's 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence had been previously described in Indian mathematics.

The first number of the That is, after two starting values, each number is the sum of the two preceding numbers. The first Fibonacci numbers (sequence A000045 in OEIS), also denoted as Fn, for n = 0, 1, 2, … ,20 are:

F0F1F2F3F4F5F6F7F8F9F10F11F12F13F14F15F16F17F18F19F20
011235813213455891442333776109871597258441816765

 

Every 3rd number of the sequence is even and more generally, every kth number of the sequence is a multiple of Fk.

The sequence extended to negative index n satisfies Fn = Fn−1 + Fn−2 for all integers n, and F−n = (−1)n+1Fn:

sequence is 0, the second number is 1, and each subsequent number is equal to the sum of the previous two numbers of the sequence itself, yielding the sequence 0, 1, 1, 2, 3, 5, 8, etc. In mathematical terms, it is defined by the following recurrence relation

:

Ordinal Number

In linguistics, ordinal numbers are the words representing the rank of a number with respect to some order, in particular order or position (i.e. first, second, third, etc.). Its use may refer to size, importance, chronology, etc. They are adjectives and, at least in English, precede the nouns they are modifying.
They are different from the cardinal numbers (one, two, three, etc.) referring to the quantity.
Ordinal numbers are alternatively written in English with numerals and letter suffixes: 1st, 2nd or 2d, 3rd or 3d, 4th, 11th, 21st, 477th, etc. In some countries, written dates omit the suffix, although it is nevertheless pronounced. For example: 4 July 1776 (pronounced "the fourth of July ... "); July 4, 1776, ("July fourth ..."). When written out in full with "of", however, the suffix is retained: the 4th of July. In other languages, different ordinal indicators are used to write ordinal numbers.
In American Sign Language, the ordinal numbers first through ninth are formed with gestures similar to those for the corresponding cardinal numbers with the addition of a small twist of the wrist.