ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

Add JavaScript programmatically using RegisterStartupScript during an Asynchronous postback

You can use below code to call JavaScript from your script page:
ScriptManager.RegisterStartupScript(Me.GetType(), "AlertMe", "alert('test');",False)
btnPostback is control, you can also give "this" for general javgaScript.


Also if you do not have ScriptManager, then you can use below code:


Dim someScript As String = "alertMe"
If (Not ClientScript.IsStartupScriptRegistered(Me.GetType(), someScript)) Then
   ClientScript.RegisterStartupScript(Me.GetType(), someScript, "alert('I was called from Content page!')"True)
End If

To get Master Page object in your page.

Use below code in your page to get Master Page object which can be used to access master page property

Put this code on top of your page:
<%@ MasterType VirtualPath="//Master Page Path" %>

No you can use master page object as
Master.Username = "test"
//Here Username is property of Master Page. Similarly you can access methods also.

Group By and Aggregates in .NET DataTable

The function first gets distinct values for group-by column, by creating a data view from source data table and using DataView’s "ToTable" method. It then loops thru these distinct values performing aggregate function on the source table using DataTable’s "Compute" method - Count in this case, but it can easily be replaced with other aggregates:



Function GroupBy(ByVal i_sGroupByColumn As String, ByVal i_sAggregateColumn As String, ByVal i_dSourceTable As DataTable) As DataTable
       Dim dv As New DataView(i_dSourceTable)
       'getting distinct values for group column
       Dim dtGroup As DataTable = dv.ToTable(True, New String() {i_sGroupByColumn}) 
       'adding column for the row count
       dtGroup.Columns.Add("Count", GetType(Integer)) 

       'looping thru distinct values for the group, counting
       For Each dr As DataRow In dtGroup.Rows
            dr("Count") = i_dSourceTable.Compute("Count(" & i_sAggregateColumn & ")", i_sGroupByColumn & " = '" & dr(i_sGroupByColumn) & "'")
       Next       
       'returning grouped/counted result
       Return dtGroup
End Function



Page Transition Effect in Internet Explorer.


Adding this code on your .html or .aspx page can generate fadding effect on every postback
try this add on of the page:

<meta http-equiv="Page-Exit" content="progid:DXImageTransform.Microsoft.Fade(duration=.5)" >


Difference between include() and include_once() in PHP

function.php

function foo(){ 
echo 'some code'; 

?>
Global.php

include('FUNCTIONS.PHP');
foo();
?>
Header.php
include('FUNCTIONS.PHP');
include('GLOBALS.PHP');
foo();
?>

now if you try to open HEADER.PHP you will get an error becauseglobal.php includes function.php already. you will get an error saying that function foo() was already declared in global.php, and i also included inHeader.php - which means i have included function.php two times. 

so to be sure i only include function.php only ONE time, i should use the include_once() function, so my Header.php should look like this: 

Header.php
include_once('FUNCTIONS.PHP');
include('GLOBALS.PHP');
?>

now when i open Header.php, i will not get an error anymore because PHP knows to include the file function.php only ONCE