Wednesday, 28 November 2012

Android Program - Webview using for loading my-Blog (URL)

In myweb->res-> layout->activity.xml

<?xml version="1.0" encoding="utf-8"?>

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>


In myweb->res-> layout->Android.manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myweb"
    android:versionCode="1"
    android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"/>
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_ak123"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Web"
            android:label="@string/title_activity_web" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


in src->web.java
package com.example.myweb;
import com.example.myweb.R;
import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;;

public class Web extends Activity {
      
    private WebView webView;
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
        webView = (WebView) findViewById (R.id.webView1);
        webView.loadUrl("http://arunphp.blogspot.in/load.php");
    }

}



output:



 

 




Tuesday, 27 November 2012

Dynamic Drop Down list and fetchin value without using ajax in asp.net

in drop.aspx

<script type="text/javascript">
        function selectDropdown() {
        var dropdownValue = document.getElementById("DropDownList1").value;
        //alert("You selected : " + dropdownValue);
        document.getElementById("Textbox1").value = dropdownValue;
   }
</script>
  
<body>
    <form id="form1" runat="server">
    <div>
    <asp:DropDownList ID="DropDownList1" runat="server">
    </asp:DropDownList>
     <asp:textbox ID="Textbox1" runat="server" CssClass="textarea"></asp:textbox>
    </div>
      </form>

in drop.aspx.cs page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

public partial class Default3 : System.Web.UI.Page
{
    static string strconn = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
    SqlConnection con = new SqlConnection(strconn);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropDownList1.Attributes.Add("onchange", "javscript:selectDropdown();");
            BindDrop();
        }
    }

    protected void BindDrop()
    {
        con.Open();
        SqlCommand comma = new SqlCommand("select username,mobilenumber from tb_reg", con);
        SqlDataAdapter da = new SqlDataAdapter(comma);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DropDownList1.DataSource = ds;
        DropDownList1.DataTextField = "username";
        DropDownList1.DataValueField = "mobilenumber";
        DropDownList1.DataBind();
        Textbox1.Text = DropDownList1.SelectedItem.Value.ToString();
        con.Close();

    }

}


Output:




simple login form in asp.net

In aspx page:

<div id="container">
    <form id="form1" runat="server">
    <div>
    <div class="head">Login Here!!!</div><br />
    <div>
        <label class="lab">email</label><asp:TextBox ID="TextBox1" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
        <label class="lab">password</label><asp:TextBox ID="TextBox2" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
        <div class="but"><asp:Button ID="Button1" runat="server" Text="Button"
                CssClass="button" onclick="Button1_Click" /> 
            <asp:Label ID="lbl" runat="server"></asp:Label>
        </div>
    </div>
    </div>
    </form>
    </div>

IN CS PAGE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class Default3 : System.Web.UI.Page
{
    static string strconn = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
    SqlConnection con = new SqlConnection(strconn);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

      
        con.Open();
        SqlCommand cmdd = new SqlCommand("select * from tb_reg where email='" + TextBox1.Text + "' AND password='" + TextBox2.Text + "'",con);  
        SqlDataAdapter da = new SqlDataAdapter(cmdd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            Session["user"] = TextBox1.Text;
            Response.Redirect("drop.aspx");   
        }
        else
        {
            lbl.Text = "login failure";
        }
        con.Close();
    }
}


simple register form in asp.net


WEB-CONFIG FILE:
<add name="reg" connectionString="Data Source=AAGNA-PC\SQLEXPRESS;Initial Catalog=sqlcon;User id=;Password=; Integrated Security=SSPI"/>

CSS-FOR FORM STYLE NAMED MAIN.CSS:

.lab{ float:left; width:20%; font-family:Verdana; font-size:12px;}
.labn{ font-family:Verdana; font-size:12px;}
.head{ font-family:Verdana; font-size:18px; color:red; padding-left:200px;}
.bor{ border:1px dashed #000; width:600px; padding-left:100px; padding-top:10px;}
#container{ width:700px; margin:0 auto 0 auto;}
.textarea {
  -webkit-transition: all 0.30s ease-in-out;
  -moz-transition: all 0.30s ease-in-out;
  -ms-transition: all 0.30s ease-in-out;
  -o-transition: all 0.30s ease-in-out;
  outline: none;
  /*padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;*/
  border: 1px solid #DDDDDD; width:200px; height:35px;
}

.textarea:focus {
  box-shadow: 0 0 5px rgba(81, 203, 238, 1);
  /*padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;*/
  border: 1px solid rgba(81, 203, 238, 1);
}
.button {
   border: 1px solid #DDD;
   border-radius: 3px;
   text-shadow: 0 1px 1px white;
   -webkit-box-shadow: 0 1px 1px #fff;
   -moz-box-shadow:    0 1px 1px #fff;
   box-shadow:         0 1px 1px #fff;
   font: bold 11px Sans-Serif;
   padding: 6px 10px;
   white-space: nowrap;
   vertical-align: middle;
   color: #666;
   background: transparent;
   cursor: pointer;
   width:150px; height:35px;
}
.button:hover, .button:focus {
   border-color: #999;
   background: -webkit-linear-gradient(top, white, #E0E0E0);
   background:    -moz-linear-gradient(top, white, #E0E0E0);
   background:     -ms-linear-gradient(top, white, #E0E0E0);
   background:      -o-linear-gradient(top, white, #E0E0E0);
   -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
   -moz-box-shadow:    0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
   box-shadow:         0 1px 2px rgba(0,0,0,0.25), inset 0 0 3px #fff;
}
.button:active {
   border: 1px solid #AAA;
   border-bottom-color: #CCC;
   border-top-color: #999;
   -webkit-box-shadow: inset 0 1px 2px #aaa;
   -moz-box-shadow:    inset 0 1px 2px #aaa;
   box-shadow:         inset 0 1px 2px #aaa;
   background: -webkit-linear-gradient(top, #E6E6E6, gainsboro);
   background:    -moz-linear-gradient(top, #E6E6E6, gainsboro);
   background:     -ms-linear-gradient(top, #E6E6E6, gainsboro);
   background:      -o-linear-gradient(top, #E6E6E6, gainsboro);
}
.but{ padding-left:130px;}



IN ASPX-FILE

 <div id="container">
      <div class="head">Registeration form</div><br />
    <form id="form1" runat="server">
    <div class="bor">
   
   
    <label class="lab">name</label><asp:TextBox ID="TextBox1" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">email</label><asp:TextBox ID="TextBox2" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">password</label><asp:TextBox ID="TextBox9" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">first name</label><asp:TextBox ID="TextBox3" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">last name</label><asp:TextBox ID="TextBox4" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">mobile number</label><asp:TextBox ID="TextBox5" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">state</label>
        <asp:TextBox ID="TextBox6" runat="server" CssClass="textarea"></asp:TextBox>
    <br /><br />
    <label class="lab">country</label><asp:TextBox ID="TextBox7" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">area</label><asp:TextBox ID="TextBox8" runat="server" CssClass="textarea"></asp:TextBox>
        <br /><br />
    <label class="lab">gender</label>
        <asp:RadioButtonList CssClass="labn"
            ID="RadioButtonList1" runat="server">
            <asp:ListItem>male</asp:ListItem>
            <asp:ListItem>female</asp:ListItem>
        </asp:RadioButtonList>
   
    <br />
    <div class="but"><asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"  CssClass="button"/></div>
    <asp:Label ID="lblr" runat="server"></asp:Label><br />
    </div>
    </form>
    </div>



IN ASPX.CS FILE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

public partial class Default2 : System.Web.UI.Page
{
    static string strconn = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;   
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(strconn);
        SqlCommand insrt = new SqlCommand("insert into tb_reg (username,email,password,firstname,lastname,mobilenumber,state,country,area,gender) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox9.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','"+ RadioButtonList1.Text +"')",con);
        con.Open();
        insrt.ExecuteNonQuery();

        //int arun;
       
        //SqlCommand sel = new SqlCommand("select * from tb_reg");
        //SqlDataAdapter da = new SqlDataAdapter(sel);
        //DataTable dt = new DataTable();
        //da.Fill(dt);
        //if (dt.Rows.Count > 0)
        //{
        //    lblr.Text = "register sucess";
        //}
        //else
        //{
        //    lblr.Text = "register failed";
        //}

        lblr.Text = "register sucess!!!";
        con.Close();

        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox9.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
        TextBox5.Text = "";
        TextBox6.Text = "";
        TextBox7.Text = "";
        TextBox8.Text = "";
        TextBox9.Text = "";



    }
}

DATABASE-FILE:
USE [sqlcon]
GO
/****** Object:  Table [dbo].[tb_reg]    Script Date: 11/28/2012 11:27:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tb_reg](
 [username] [varchar](50) NULL,
 [email] [varchar](50) NULL,
 [password] [varchar](50) NULL,
 [firstname] [varchar](50) NULL,
 [lastname] [varchar](50) NULL,
 [mobilenumber] [bigint] NULL,
 [state] [varchar](50) NULL,
 [country] [varchar](50) NULL,
 [area] [varchar](50) NULL,
 [gender] [varchar](50) NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

OUTPUT:


Sunday, 25 November 2012

Asp.net config file for upload datas in sql db

webconfig file:
<connectionStrings>
    <add name="arunkumar" connectionString="Data Source=AAGNA-PC\SQLEXPRESS;Initial Catalog=giri;Integrated Security=true;User id=sa;Password=;"/>
  </connectionStrings>

in public class file:
static string strcon = ConfigurationManager.ConnectionStrings["arunkumar"].ConnectionString;
    SqlConnection con = new SqlConnection(strcon);

button_click coding:
 protected void Button1_Click(object sender, EventArgs e)
    {
        //SqlConnection con = new SqlConnection("data source=AAGNA-PC;I ntegrated Security=SSPI;Initial Catalog:tb_login ;User Instance=true;");
        con.Open();
        SqlCommand cmd = new SqlCommand("insert into tb_login(username,password) values('"+ txt.Text  +"','"+ txt1.Text +"') ", con);
        cmd.ExecuteNonQuery();
        con.Close();
    }


button_click for grid view display:
protected void Button2_Click(object sender, EventArgs e)
    {
        SqlCommand cmd1 = new SqlCommand("select * from tb_login",con);
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter(cmd1);
        DataTable dt = new DataTable();
        da.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();

    }

database sql coding :
after creating database named giri after workout this query !

USE [giri]
GO
/****** Object:  Table [dbo].[tb_login]    Script Date: 11/26/2012 12:30:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tb_login](
    [username] [varchar](50) NULL,
    [password] [varchar](50) NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

output :


jQuery for moving background alone

  script for moving bg alone like cloud moving:
 
<script type="text/javascript" charset="utf-8">
   var scrollSpeed = 50;   // Speed in milliseconds
   var step = 1;     // How many pixels to move per step
   var current = 0;   // The current pixel row
   var imageWidth = 2247;  // Background image width
   var headerWidth = 2000;  // How wide the header is.
   
   //The pixel row where to start a new loop
   var restartPosition = -(imageWidth - headerWidth);
   
   function scrollBg(){
    //Go to next pixel row.
    current -= step;
    
    //If at the end of the image, then go to the top.
    if (current == restartPosition){
     current = 0;
    }
    
    //Set the CSS of the header.
    $('body').css("background-position",current+"px 0");
   }
   
   //Calls the scrolling function repeatedly
   var init = setInterval("scrollBg()", scrollSpeed);
 </script>

Thursday, 25 October 2012

jquery for keyup function typing aswell append the datas to screen

<html>
<head>
  <style>

  p { color:blue; margin:8px; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="text" value="some text"/>
  <p></p>
<script>
    $(document).ready(function() {
    $("input").keyup(function () {
      var value = $(this).val();
      $("p").text(value);
    }).keyup();
    });
</script>

</body>
</html>

php for youtube upload by using url


<form action="tube.php" method="post">
<input type="text" name="id" />
<input type="text" name="you" />
<input type="submit" value="submit" />
</form>
<?php  $con=mysql_connect("localhost","root","");
mysql_select_db("tube",$con);
$long = $_POST['you'];
$id = $_POST['id'];
mysql_query("INSERT INTO `youtube`(`id`, `url`) VALUES ('$id','$long')") or die("unable to connect");
$query=mysql_query("SELECT `id`, `url` FROM `youtube` where `id`=1");
while($res=mysql_fetch_array($query))
{
   
?>
<?php

$longString = $res['url'];
$len=strlen($longString );

?>
<?php
if($len>43)
{
 ?>
<iframe width="560" height="315"  id="cs" src="
<?php


$b = substr($longString , strpos($longString , 'watch?v') + 1);


$c = substr($b, 0, strpos($b, '&'));

$str2 = substr($c, 7);


/*
echo substr_replace($c, '', 15) . "<br />\n";
echo "<br>";
$d = substr($a, 0, strpos($a, '='));
print $d; // prints 9999 */

$mn=substr_replace($longString , 'embed/', 23);

$mn .=$str2;

echo $mn;





?>" frameborder="0" allowfullscreen></iframe><?php } else {?>


<?php

$separator = 'embed/';
$separatorlength = strlen($separator) ;
$maxlength =53 - $separatorlength;
$start = $maxlength / 2 ;
$trunc =  strlen($longString) - $maxlength;

$st= substr_replace($longString, $separator, $start);
echo "<br>";
$st.=substr($longString,31);




?>
<iframe width="560" height="315" src="<?php echo $st; ?>" frameborder="0" allowfullscreen></iframe><?php } ?> <br /><br /><br /> <?php }?>

print the screen-js

<A HREF="javascript:window.print()">Click to Print This Page</A>

youtube side bar-scroll control

 <nav>
    <ul style="padding:40px;" id="uli">
        <li>
            <a href="#10"><img src="thumbimages/aaviskar.png" width="110" style="margin-bottom:5px;" /></a>
        </li>
       
           <li>
            <a href="#16"><img src="thumbimages/daksha2.png" width="110"  style="margin-bottom:5px;"/></a>
        </li>
       
        <li>
            <a href="#11"><img src="thumbimages/nehru.png"  width="110" style="margin-bottom:5px;"/></a>
        </li>
              <li>
            <a href="#17"><img src="thumbimages/daksha1.png" width="110" style="margin-bottom:5px;" /></a>
        </li>
       
        <li>
            <a href="#13"><img src="thumbimages/black.png" width="110" style="margin-bottom5px;" /></a>
        </li>
      
        <li>
            <a href="#12"><img src="thumbimages/dhall.png" width="110"  style="margin-bottom:5px;"/></a>
        </li>
   
           
       
       
       
        <li>
            <a href="#14"><img src="thumbimages/aaga.png" width="110" style="margin-bottom:5px;" /></a>
        </li>
        <li>
            <a href="#15"><img src="thumbimages/maharajroof.png" width="110"  style="margin-bottom:5px;"/></a>
        </li>
    
 
    </ul>
</nav>
             


implement this in header section



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   
    $('nav ul li a').click(function(){
   
        var el = $(this).attr('href');
        var elWrapped = $(el);
       
        scrollToDiv(elWrapped,300);
       
        return false;
   
    });
   
    function scrollToDiv(element,navheight){
   
       
   
        var offset = element.offset(90);
        var offsetTop = offset.top;
        var totalScroll = offsetTop-navheight;
       
        $('#b2').animate({
                scrollTop: totalScroll
        },500);
   
    }
   
   
   
});
</script>