Friday, 17 May 2013

How to use DataView ToTable method to create a new DataTable in ado.net

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        DataTable dt = new DataTable();
        dt.TableName = "Books";

        DataColumn dc1 = new DataColumn();
        dc1.ColumnName = "BookID";
        dc1.DataType = typeof(int);
        dc1.AllowDBNull = false;
        dc1.Unique = true;

        DataColumn dc2 = new DataColumn();
        dc2.ColumnName = "Category";
        dc2.DataType = typeof(string);

        DataColumn dc3 = new DataColumn();
        dc3.ColumnName = "BookName";
        dc3.DataType = typeof(string);

        DataColumn dc4 = new DataColumn();
        dc4.ColumnName = "Author";
        dc4.DataType = typeof(string);

        dt.Columns.AddRange(new DataColumn[] { dc1, dc2, dc3, dc4 });

        dt.Rows.Add(new object[] { 1, "iPhone", "iPhone User Interface Cookbook: RAW", "Cameron Banga" });
        dt.Rows.Add(new object[] { 2, "MySQL", "MySQL 5.1 Plugin Development", "Andrew Hutchings, Sergei Golubchik" });
        dt.Rows.Add(new object[] { 3, "MySQL", "MySQL Admin Cookbook", "Daniel Schneller, Udo Schwedt" });
        dt.AcceptChanges();

        Label1.Text = "Source DataTable";
        GridView1.DataSource = dt.DefaultView;
        GridView1.DataBind();

        //this line create a new DataView
        DataView dView = new DataView(dt);
        dView.RowFilter = "Category = 'MySQL'";

        Label2.Text = "Here we create a new DataView<br />" +
                      "and set the RowFilter (Category = 'MySQL')";

        GridView2.DataSource = dView;
        GridView2.DataBind();

        //this line create a new DataTable from DataView
        DataTable dt2 = dView.ToTable();

        Label3.Text = "Here we create a new DataTable from DataView";
        GridView3.DataSource = dt2;
        GridView3.DataBind();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to use DataView ToTable method to create a new DataTable in ado.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:DarkBlue; font-style:italic;">
            How to use DataView ToTable method
            <br /> to create a new DataTable in ado.net
        </h2>
        <hr width="450" align="left" color="CornFlowerBlue" />
        <asp:Label
             ID="Label1"
             runat="server"
             Font-Size="Large"
             ForeColor="DodgerBlue"
             Font-Italic="true"
             >
        </asp:Label>
        <asp:GridView
            ID="GridView1"
            runat="server"
            BorderColor="Snow"
            ForeColor="Snow"
            Width="600"
            Font-Names="Courier"
            >
            <HeaderStyle BackColor="DarkSlateBlue" Height="30" />
            <RowStyle BackColor="MediumVioletRed" />
            <AlternatingRowStyle BackColor="PaleVioletRed" />
        </asp:GridView>
        <br />
        <asp:Label
             ID="Label2"
             runat="server"
             Font-Size="Large"
             ForeColor="DodgerBlue"
             Font-Italic="true"
             >
        </asp:Label>
        <asp:GridView
            ID="GridView2"
            runat="server"
            BorderColor="Snow"
            ForeColor="Snow"
            Width="600"
            Font-Names="Courier"
            >
            <HeaderStyle BackColor="DarkSlateBlue" Height="30" />
            <RowStyle BackColor="MediumVioletRed" />
            <AlternatingRowStyle BackColor="PaleVioletRed" />
        </asp:GridView>
        <br />
        <asp:Label
             ID="Label3"
             runat="server"
             Font-Size="Large"
             ForeColor="DodgerBlue"
             Font-Italic="true"
             >
        </asp:Label>
        <asp:GridView
            ID="GridView3"
            runat="server"
            BorderColor="Snow"
            ForeColor="Snow"
            Width="600"
            Font-Names="Courier"
            >
            <HeaderStyle BackColor="DarkSlateBlue" Height="30" />
            <RowStyle BackColor="MediumVioletRed" />
            <AlternatingRowStyle BackColor="PaleVioletRed" />
        </asp:GridView>
        <asp:Button
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Populate GridView"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>


Thursday, 16 May 2013

Information about visitor's browser , visitor browser details


<!--this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
</head>

<body>

<!-- Start of Browser ID JavaScript-->
<!-- This Script allows the visitor to click on the buttons to display their browser's info -->
<!-- Instructions: Just put the beginning of this script between your pages open and closing
head tags and the later part in the body where you want it displayed in your page.  -->
<!-- Script supplied with CoffeeCup HTML Editor -->
<!--             www.coffeecup.com              -->
<head><script>
 <!--
 function CC_getBrowserName()   {  
         document.forms[0].elements[0].value =navigator.appName;    
 }

 function CC_getBrowserVersion()   {  
         document.forms[0].elements[0].value =  navigator.appVersion;    
 }

 function CC_getBrowserCodeName()   {  
         document.forms[0].elements[0].value = navigator.appCodeName;    
 }

 function CC_getBrowserUserAgent()   {  
         document.forms[0].elements[0].value =  navigator.userAgent;    
 }

 function CC_getBrowserNameVersion()   {  
         document.forms[0].elements[0].value = navigator.appName + " " + navigator.appVersion;    
 }

 // -->
 </script>
 </head>
 <center>

<center>
 <form NAME="detect">
 <input TYPE="text" NAME="browser" SIZE="26" MAXLENGTH="40" VALUE="Browser Detection"><br>
 <br><br>Choose a button to reveal your browser's self image.<br>
 <input TYPE="button" VALUE="appName" onClick="CC_getBrowserName()">
 <input TYPE="button" VALUE="appVersion" onClick="CC_getBrowserVersion()">
 <input TYPE="button" VALUE="appCodeName" onClick="CC_getBrowserCodeName()">
 <input TYPE="button" VALUE="userAgent" onClick="CC_getBrowserUserAgent()">
 <input TYPE="button" VALUE="appName / appVersion" onClick="CC_getBrowserNameVersion()"><br><br><br>
 </form>
 </center><p>
<!-- End of Browser ID JavaScript-->

Today's Date in website


<!-- this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
<!-- ONE STEP TO INSTALL MONTHLY:  DAY HIGHLIGHTED:

   1.  Put the code into the BODY of your HTML document  -->
<!-- STEP ONE: Copy this code into the HEAD your HTML document  -->
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body>

<center>
<script LANGUAGE="JavaScript">

<!-- Begin
monthnames = new Array(
"January",
"Februrary",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"Decemeber");
var linkcount=0;
function addlink(month, day, href) {
var entry = new Array(3);
entry[0] = month;
entry[1] = day;
entry[2] = href;
this[linkcount++] = entry;
}
Array.prototype.addlink = addlink;
linkdays = new Array();
monthdays = new Array(12);
monthdays[0]=31;
monthdays[1]=28;
monthdays[2]=31;
monthdays[3]=30;
monthdays[4]=31;
monthdays[5]=30;
monthdays[6]=31;
monthdays[7]=31;
monthdays[8]=30;
monthdays[9]=31;
monthdays[10]=30;
monthdays[11]=31;
todayDate=new Date();
thisday=todayDate.getDay();
thismonth=todayDate.getMonth();
thisdate=todayDate.getDate();
thisyear=todayDate.getYear();
thisyear = thisyear % 100;
thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
if (((thisyear % 4 == 0)
&& !(thisyear % 100 == 0))
||(thisyear % 400 == 0)) monthdays[1]++;
startspaces=thisdate;
while (startspaces > 7) startspaces-=7;
startspaces = thisday - startspaces + 1;
if (startspaces < 0) startspaces+=7;
document.write("<table border=2 bgcolor=white ");
document.write("bordercolor=black><font color=black>");
document.write("<tr><td colspan=7><center><strong>"
+ monthnames[thismonth] + " " + thisyear
+ "</strong></center></font></td></tr>");
document.write("<tr>");
document.write("<td align=center>Su</td>");
document.write("<td align=center>M</td>");
document.write("<td align=center>Tu</td>");
document.write("<td align=center>W</td>");
document.write("<td align=center>Th</td>");
document.write("<td align=center>F</td>");
document.write("<td align=center>Sa</td>");
document.write("</tr>");
document.write("<tr>");
for (s=0;s<startspaces;s++) {
document.write("<td> </td>");
}
count=1;
while (count <= monthdays[thismonth]) {
for (b = startspaces;b<7;b++) {
linktrue=false;
document.write("<td>");
for (c=0;c<linkdays.length;c++) {
if (linkdays[c] != null) {
if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)) {
document.write("<a href=\"" + linkdays[c][2] + "\">");
linktrue=true;
      }
   }
}
if (count==thisdate) {
document.write("<font color='FF0000'><strong>");
}
if (count <= monthdays[thismonth]) {
document.write(count);
}
else {
document.write(" ");
}
if (count==thisdate) {
document.write("</strong></font>");
}
if (linktrue)
document.write("</a>");
document.write("</td>");
count++;
}
document.write("</tr>");
document.write("<tr>");
startspaces=0;
}
document.write("</table></p>");
// End -->
</script>
</center>
<!-- Script Size:  2.98 KB  -->

</body>

</html>

<!-- END CODE - Powered javascript code by WWW.webloger.5u.COM &#1591;&#1585;&#1575;&#1581;&#1740; &#1608;&#1576;&#1604;&#1575;&#1711;-->

<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>

popup in javascript


<!-- this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
<HTML>
<HEAD>
<!--START OF PopUp on Button Click-->
<!-This script will give you 4 buttons that display pop up windows when clicked. -->
<!-- Instructions:
1.  Copy the coding into the HEAD of your HTML document
2.  Add the last code into the BODY of your HTML document  -->
<!-- Script supplied with CoffeeCup HTML Editor -->
<!--             www.coffeecup.com              -->
<SCRIPT LANGUAGE="JavaScript">
function AlertCC(label, msg)
{
  var cc1 =
    "<TITLE>Window Title</TITLE>" +
    "<BODY BGCOLOR='FFFFFF'><TABLE BORDER=0><TR>" +
        "<TD WIDTH=90% HEIGHT=90 VALIGN=TOP ALIGN=LEFT>"+
        "<FONT SIZE=4 FACE=ARIAL>"
 
  var cc2 = "<FONT COLOR='FF0000'><B>"+label+"</B></FONT><BR><P>"

  var cc3 =  
    "</TD><TD WIDTH=10%> </TD></TR><TR><TD> </TD>"+
    "<TD VALIGN=BOTTOM ALIGN=RIGHT>"+
    "<FORM><INPUT TYPE='BUTTON' VALUE='Close Window'" +
                   "onClick='self.close()'>"  +
    "</FORM></TD></TR></TABLE></BODY>"


  popup = window.open("","popDialog","height=280,width=400,scrollbars=no")
  popup.document.write(cc1+cc2+msg+cc3)
  popup.document.close()
}

function ccalert1()
{
  AlertCC('Alert One', 'This script will let you place information about your product or topic of choice.')
}
function ccalert2()
{
  AlertCC('Alert Two', 'This script will let you place information about your product or topic of choice.')
}
function ccalert3()
{
  AlertCC('Alert Three', 'This script will let you place information about your product or topic of choice.')
}
function ccalert4()
{
  AlertCC('Alert Four', 'This script will let you place information about your product or topic of choice.')
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER><FORM><INPUT TYPE="BUTTON" VALUE="[ Alert One ]" onClick="ccalert1()"></FORM></CENTER><p>
<CENTER><FORM><INPUT TYPE="BUTTON" VALUE="[ Alert Two ]" onClick="ccalert2()"></FORM></CENTER><p>
<CENTER><FORM><INPUT TYPE="BUTTON" VALUE="[ Alert Three ]" onClick="ccalert3()"></FORM></CENTER><p>
<CENTER><FORM><INPUT TYPE="BUTTON" VALUE="[ Alert Four ]" onClick="ccalert4()"></FORM></CENTER><p>
<!-- END OF SCRIPT -->


<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>

print button in webpage


<!-- this script got from www.javascriptfreecode.com coded by: Krishna Eydatoula-->

<input type=button name=print value="Print this page" onClick="javascript:window.print()">



<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>

no copy, stop copy , stop ctrl C


<!--this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
<!-- Right Click - Prevent Script
Use this link to help prevent users from stealing your code !-->

<script language="JavaScript">
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Please don't steal my stuff!!!");
return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
</script>


disable right click , stop mouse right click, no right click, mouse right click


<!-- this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula -->
</style>
<SCRIPT language=JavaScript>
document.onmousedown=click
var times=0
var times2=10
function click() {
if ((event.button==2) || (event.button==3)) {
if (times>=1) { bye() }
alert("No right clicking!!!!!! don't do it again..");
times++ } }
function bye() {
alert("I said NO right clicking! click ok to exit LMAO!");
bye() }
</SCRIPT>

<font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>