<?php if(isset($_POST['Submit'])) { $from=$_POST['uname']; $t=$_POST['email']; $y=$_POST['post']; $rr=$_FILES['file']['strresume']; $to="letters/".$_FILES['strresume']['name']; move_uploaded_file($_FILES['strresume']['tmp_name'],$to); $fileatt = "letters/".$_FILES['strresume']['name']; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = "CV_".$_FILES['strresume']['name']; // Filename that will be used for the file as the attachment $email_from = $_POST['nume']." ".$_POST['prenume']; // Who the email is from $email_subject = "CV".$_FILES['strresume']['name']; // The Subject of the email //here you define the body of the message, the message itself //you can modify the "post" textfield in sendmail.php to a textarea.... $email_message ="Name:".$from; $email_message.="\r\n"; //$email_message.=$_POST['uname']; $email_message.="Email:".$_POST['email']; $email_message.="\r\n"; //$email_message.="Post Applied For:" $email_message.="Post Applied For:". $_POST['post']; // Message that the email has in it //here you enter the e-mail address to wich you want the message to be sent $email_to = " vivekamcbseschool@gmail.com"; // Who the email is too //adds the e-mail address of the sender $headers = "From: ".$_POST['email']; $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n"; /********************************************** First File ********************************************/ //$filleant takes the value of the picture that was jut uploaded with the unique name to the ftp in the www.yourname.com/upload/upload $fileatt = "letters/".$_FILES['strresume']['name']; // Path to the file $fileatt_type = "application/octet-stream"; // File Type //here i made the file that will be sent as attachment to have the name "CV_name_surname.doc" you can make it what format you like, //i needed the doc format... and i'll modify this code to accept just doc file later...i'm really tired right now :D $fileatt_name = "CV".$_FILES['strresume']['name']; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}\n"; unset($data); unset($file); unset($fileatt); unset($fileatt_type); unset($fileatt_name); /********************************************** End of File Config ********************************************/ // To add more files just copy the file section again, but make sure they are all one after the other! If they are not it will not work! $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) {?> <script> alert("Thanks for applying at Vivekam careers! will get back to you soon!"); window.location="careers.php"; </script> <?php } } ?>
Thursday, 7 March 2013
mail Attachement in php
Sunday, 10 February 2013
AJAX-JQUERY-PHP
<script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript">function searchNow() {var a=$("#h").val();var b=$("#hi").val();var dataString = 'name='+ a + '&namei=' + b;//your validation code$.ajax( {type:"POST",async: false,url:"register.php",data: dataString,success: function(data)
{alert("test");$("#message").html(data);}} );}</script><input type = "text" name = "name" id="h"><input type = "text" name = "namei" id="hi" ><input type = "button" name = "name" id="i" onClick="searchNow();"><div id="message"></div>
//in regisrer.php:$a=$_POST['name'];$b=$_POST['namei'];echo $a;echo "<br>";echo $b;
Thursday, 20 December 2012
jQuery selected tab on postback -Asp.net C#
Its used to store the current tab after postback or reload the current page
in Style.css
.ui-tabs {
zoom: 1;
}
.ui-tabs .ui-tabs-nav {
list-style: none;
position: relative;
padding: 0;
margin: 0;
}
.ui-tabs .ui-tabs-nav li {
position: relative;
float: left;
margin: 0 3px -2px 0;
padding: 0;
}
.ui-tabs .ui-tabs-nav li a {
display: block;
padding: 10px 20px;
background: #f0f0f0;
border: 2px #ccc solid;
border-bottom-color: #ccc;
outline: none;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a {
padding: 10px 20px 12px 20px;
background: #fff;
border-bottom-style: none;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
.ui-tabs .ui-tabs-nav li.ui-state-disabled a,
.ui-tabs .ui-tabs-nav li.ui-state-processing a {
cursor: default;
}
.ui-tabs .ui-tabs-nav li a,
.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
cursor: pointer;
}
.ui-tabs .ui-tabs-panel {
display: block;
clear: both;
border: 2px #ccc solid;
padding: 10px;
}
.ui-tabs .ui-tabs-hide {
display: none;
}
.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 Style.css
.ui-tabs {
zoom: 1;
}
.ui-tabs .ui-tabs-nav {
list-style: none;
position: relative;
padding: 0;
margin: 0;
}
.ui-tabs .ui-tabs-nav li {
position: relative;
float: left;
margin: 0 3px -2px 0;
padding: 0;
}
.ui-tabs .ui-tabs-nav li a {
display: block;
padding: 10px 20px;
background: #f0f0f0;
border: 2px #ccc solid;
border-bottom-color: #ccc;
outline: none;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a {
padding: 10px 20px 12px 20px;
background: #fff;
border-bottom-style: none;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
.ui-tabs .ui-tabs-nav li.ui-state-disabled a,
.ui-tabs .ui-tabs-nav li.ui-state-processing a {
cursor: default;
}
.ui-tabs .ui-tabs-nav li a,
.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
cursor: pointer;
}
.ui-tabs .ui-tabs-panel {
display: block;
clear: both;
border: 2px #ccc solid;
padding: 10px;
}
.ui-tabs .ui-tabs-hide {
display: none;
}
.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;}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.tabs.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".ui-tabs").tabs();
$('.ui-tabs').bind('tabsselect', function (event, ui) {
var selectedTab = ui.index;
$("#<%= hidLastTab.ClientID %>").val(selectedTab);
});
});
</script>
<body>
<div class="ui-tabs">
<ul class="ui-tabs-nav">
<li><a href="#tabs-1">Tab One</a></li>
<li><a href="#tabs-2">Tab Two</a></li>
<li><a href="#tabs-3">Tab Three</a></li>
</ul>
<div id="tabs-1" class="ui-tabs-panel">
<form id="form1" runat="server">
<asp:HiddenField ID="hidLastTab" runat="server" Value="0" />
<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>
</div>
<div id="tabs-2" class="ui-tabs-panel">
<div class="head">Registeration form</div><br />
<div class="bor">
<label class="lab">name</label><asp:TextBox ID="TextBox3" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">email</label><asp:TextBox ID="TextBox4" 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="TextBox5" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">last name</label><asp:TextBox ID="TextBox6" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">mobile number</label><asp:TextBox ID="TextBox7" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">state</label>
<asp:TextBox ID="TextBox8" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">country</label><asp:TextBox ID="TextBox15" runat="server" CssClass="textarea"></asp:TextBox>
<br /><br />
<label class="lab">area</label><asp:TextBox ID="TextBox10" 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="Button2" runat="server" Text="Button" onclick="Button2_Click" CssClass="button"/></div>
<asp:Label ID="lblr" runat="server"></asp:Label><br />
</div>
</div>
<div id="tabs-3" class="ui-tabs-panel">
<p>Content three.</p>
<asp:Button ID="Button3" runat="server" Text="Button" onclick="Button3_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</div>
</body>
in 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.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class Default6 : System.Web.UI.Page
{
static string strconn = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
SqlConnection con = new SqlConnection(strconn);
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "selecttab", "$('.ui-tabs').tabs({ selected: " + hidLastTab.Value + " });", true);
}
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();
}
protected void Button2_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 ('" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox9.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox15.Text + "','" + TextBox10.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 = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
Label1.Text = "test";
}
}
Friday, 14 December 2012
Android Program for Internal Login page creation & count option using button
res>layout>activity_log_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LogMainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:text="Name" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="28dp"
android:text="Password" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/textView2"
android:layout_marginRight="15dp"
android:ems="10" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignLeft="@+id/editText2"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginLeft="58dp"
android:layout_marginTop="28dp"
android:text="Button" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_alignTop="@+id/button1"
android:layout_marginLeft="22dp"
android:layout_marginTop="32dp"
android:src="@drawable/ic_sel" />
</RelativeLayout>
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="submit" />
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
src>LogMainActivity
package com.example.loginusers;
import android.os.Bundle;
import com.example.loginusers.R;
import android.widget.EditText;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;
import android.content.Intent;
import android.view.View.OnClickListener;
import android.view.*;
public class LogMainActivity extends Activity {
private EditText edit,edit1;
private Button but;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_main);
addKeyListener();
}
public void addKeyListener()
{
edit= (EditText) findViewById(R.id.editText1);
edit1= (EditText) findViewById(R.id.editText2);
but=(Button) findViewById(R.id.button1);
but.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
String a=(edit.getText().toString());
String b=(edit1.getText().toString());
if(a.equals("arun") && b.equals("arun"))
{
Intent i = new Intent(LogMainActivity.this, Mainfun.class);
startActivity(i);
}
else
{
Toast.makeText(LogMainActivity.this,"please enter valid details", Toast.LENGTH_LONG).show();
}
}
});
}
}
Mainfun.java
package com.example.loginusers;
import android.app.Activity;
import com.example.loginusers.R;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.view.*;
import android.widget.Button;
import android.widget.TextView;
public class Mainfun extends Activity{
private Button but1;
private TextView text3;
private int count=0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addKeyListener();
}
public void addKeyListener()
{
but1=(Button) findViewById(R.id.button1);
text3=(TextView)findViewById(R.id.textView10);
but1.setOnClickListener(new OnClickListener()
{
public void onClick(View arg0)
{
count++;
text3.setText("you are the" +count);
}
});
}
}
Android Mainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loginusers"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="9" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.loginusers.LogMainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Mainfun"
android:label="Welcome"></activity>
</application>
</manifest>
Output:
Thursday, 13 December 2012
Admin panel for uploading & retrieving image by using folder in PHP
Css for Adminpanel .php:
#container{ width:700px; margin:0 auto 0 auto;}
#main{ width:700px; height:500px;}
#main0{ width:200px; height:500px; float:left;}
#main1{ width:500px; float:left; height:500px; background:url(images/back.png);}
.pad{ padding-left:100px;}
.fnt{ font-size:25px; font-family: Tahoma, sans-serif; color:#3490b7;}
.lab{ float:left; width:30%; text-align:right; margin-right:15px;}
#frm{ padding-left:100px;}
.text{padding: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;
width: 180px;
font-family: Helvetica, sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
border: 2px solid #CCC;}
.submit{-webkit-box-align: center;
text-align: center;
cursor: default;
color: buttontext;
padding: 2px 6px 3px;
border: 2px outset buttonface;
border-image: initial;
background-color: buttonface;
box-sizing: border-box;
padding: 5px;
width: 80px;
font-family: Helvetica, sans-serif;
font-size: 1.2em;
border: 2px solid #CCC;
}
.fontad{font-family: Helvetica, sans-serif;
font-size: 1.2em;}
.imgpad{ padding-left:150px;}
Admin-panel.php:
<div id="container">
<div id="main ">
<div id="main0"><img src="images/admin.png" /></div>
<div id="main1">
<div id="wel">
<p class="pad fnt">Welocome To Admin Panel !!!</p>
</div>
<div class="imgpad"><img src="images/admin123.png" /></div>
<div id="frm">
<form action="adminpanel.php" method="post">
<label class="lab fontad">Admin-Name</label>
<input type="text" name="admin" class="text" /><br /><br />
<label class="lab fontad">Password</label>
<input type="password" name="pass" class="text" /><br /><br />
<div style="padding-left:250px;"><input type="submit" name="submit1" class="submit" /></div>
</form>
</div>
</div>
</div>
</div>
in admin.php:
<form action="upload.php" method="post" enctype="multipart/form-data" >
<input type="hidden" name="upload" value="1" />
<input type="file" name="file" id="file" class="validate[required] text-input text" /><br /><br />
<div style="padding-left:250px;"><input type="submit" name="btnSubmit" value="Submit" class="button3 orange button_wid submit" /></div>
</form>
in upload.php:
<?php
if($_POST[upload]==1)
{
$to="upload/".$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$to);
echo '<img src="'.$to.'">';
}
?>
#container{ width:700px; margin:0 auto 0 auto;}
#main{ width:700px; height:500px;}
#main0{ width:200px; height:500px; float:left;}
#main1{ width:500px; float:left; height:500px; background:url(images/back.png);}
.pad{ padding-left:100px;}
.fnt{ font-size:25px; font-family: Tahoma, sans-serif; color:#3490b7;}
.lab{ float:left; width:30%; text-align:right; margin-right:15px;}
#frm{ padding-left:100px;}
.text{padding: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;
width: 180px;
font-family: Helvetica, sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
border: 2px solid #CCC;}
.submit{-webkit-box-align: center;
text-align: center;
cursor: default;
color: buttontext;
padding: 2px 6px 3px;
border: 2px outset buttonface;
border-image: initial;
background-color: buttonface;
box-sizing: border-box;
padding: 5px;
width: 80px;
font-family: Helvetica, sans-serif;
font-size: 1.2em;
border: 2px solid #CCC;
}
.fontad{font-family: Helvetica, sans-serif;
font-size: 1.2em;}
.imgpad{ padding-left:150px;}
Admin-panel.php:
<div id="container">
<div id="main ">
<div id="main0"><img src="images/admin.png" /></div>
<div id="main1">
<div id="wel">
<p class="pad fnt">Welocome To Admin Panel !!!</p>
</div>
<div class="imgpad"><img src="images/admin123.png" /></div>
<div id="frm">
<form action="adminpanel.php" method="post">
<label class="lab fontad">Admin-Name</label>
<input type="text" name="admin" class="text" /><br /><br />
<label class="lab fontad">Password</label>
<input type="password" name="pass" class="text" /><br /><br />
<div style="padding-left:250px;"><input type="submit" name="submit1" class="submit" /></div>
</form>
</div>
</div>
</div>
</div>
<?
if(isset($_POST['submit1']))
{
$a=$_POST['admin'];
$b=$_POST['pass'];
if($a=="admin" && $b=="admin")
{?>
<script> window.location="admin.php" </script>
<? }
else
{?>
<script> alert("please enter valid username & password")</script>
<? }
}
?>
in admin.php:
<form action="upload.php" method="post" enctype="multipart/form-data" >
<input type="hidden" name="upload" value="1" />
<input type="file" name="file" id="file" class="validate[required] text-input text" /><br /><br />
<div style="padding-left:250px;"><input type="submit" name="btnSubmit" value="Submit" class="button3 orange button_wid submit" /></div>
</form>
in upload.php:
<?php
if($_POST[upload]==1)
{
$to="upload/".$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$to);
echo '<img src="'.$to.'">';
}
?>
Friday, 7 December 2012
Grid view edit delete and update in asp.net
Database-SQL
USE [sqlcon]
GO
/****** Object: Table [dbo].[myTable] Script Date: 12/08/2012 10:08:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[myTable](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[PageName] [varchar](50) NULL,
[PageDescription] [varchar](500) NULL,
[Active] [bit] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
Stored Procedure :
USE [sqlcon]
GO
/****** Object: StoredProcedure [dbo].[spUpdateData] Script Date: 12/08/2012 10:09:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spUpdateData]
@AutoID [int],
@PageName [varchar](50),
@PageDescription [varchar](500),
@Active [Bit]
AS
UPDATE myTable
SET PageName=@PageName,
PageDescription=@PageDescription ,
Active=@Active
WHERE AutoID=@AutoID
IN ASPX-Page :
<form id="form1" runat="server">
<div>
<asp:Label ID="lblMessage" runat="Server" ForeColor="Red"></asp:Label>
<asp:GridView ID="GridView1" runat="Server" AutoGenerateColumns="False" BorderWidth="1"
DataKeyNames="AutoID" AutoGenerateEditButton="True" OnRowEditing="EditRecord"
OnRowCancelingEdit="CancelRecord" OnRowUpdating="UpdateRecord" CellPadding="4"
HeaderStyle-HorizontalAlign="left" OnRowDeleting="DeleteRecord" RowStyle-VerticalAlign="Top"
ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundField DataField="AutoID" HeaderText="AutoID" ReadOnly="True" />
<asp:TemplateField HeaderText="Page Name">
<ItemTemplate>
<%# Eval("PageName") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPageName" runat="Server" Text='<%# Eval("PageName") %>' Columns="30"></asp:TextBox>
<asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtPageName"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Page Description">
<ItemTemplate>
<%# Eval("PageDescription") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPageDesc" runat="Server" TextMode="MultiLine" Rows="10" Columns="50"
Text='<%# Eval("PageDescription") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="req2" runat="Server" Text="*" ControlToValidate="txtPageDesc"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<%# Eval("Active") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropActive" runat="server" SelectedValue='<%# Eval("Active").ToString().ToLower().Equals("true") ? "True" : "False" %>'>
<asp:ListItem Text="Yes" Value="True"></asp:ListItem>
<asp:ListItem Text="No" Value="False"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<span onclick="return confirm('Are you sure to Delete the record?')">
<asp:LinkButton ID="lnkB" runat="Server" Text="Delete" CommandName="Delete"></asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" VerticalAlign="Top" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
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.Web.Configuration;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class samplegrid : System.Web.UI.Page
{
static string connStr = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
SqlDataAdapter dAd = new SqlDataAdapter("select * from myTable", conn);
DataSet dSet = new DataSet();
try
{
dAd.Fill(dSet, "PagesData");
GridView1.DataSource = dSet.Tables["PagesData"].DefaultView;
GridView1.DataBind();
}
catch (Exception ee)
{
lblMessage.Text = ee.Message.ToString();
}
finally
{
dSet.Dispose();
dAd.Dispose();
conn.Close();
conn.Dispose();
}
}
protected void EditRecord(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindData();
}
protected void CancelRecord(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindData();
}
protected void UpdateRecord(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
int autoid = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
TextBox tPageName = (TextBox)row.FindControl("txtPageName");
TextBox tPageDesc = (TextBox)row.FindControl("txtPageDesc");
DropDownList dActive = (DropDownList)row.FindControl("dropActive");
//SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ToString());
SqlCommand dCmd = new SqlCommand();
try
{
conn.Open();
dCmd.CommandText = "spUpdateData";
dCmd.CommandType = CommandType.StoredProcedure;
dCmd.Parameters.Add("@AutoID", SqlDbType.Int).Value = autoid;
dCmd.Parameters.Add("@PageName", SqlDbType.VarChar, 50).Value = tPageName.Text.Trim();
dCmd.Parameters.Add("@PageDescription", SqlDbType.VarChar, 500).Value = tPageDesc.Text.Trim();
dCmd.Parameters.Add("@Active", SqlDbType.Bit).Value = bool.Parse(dActive.SelectedValue);
dCmd.Connection = conn;
dCmd.ExecuteNonQuery();
//conn.Open();
//SqlCommand cmd = new SqlCommand("update myTable SET PageName='"+tPageName.Text+"',PageDescription='"+tPageDesc.Text+"',Active='"+dActive.SelectedValue+"' where AutoID='"+autoid+"'", conn);
//int result = cmd.ExecuteNonQuery();
//conn.Close();
//if (result == 1)
//{
// BindData();
//}
//lblMessage.Text = "Record Updated successfully.";
// Refresh the data
GridView1.EditIndex = -1;
BindData();
}
catch (SqlException ee)
{
lblMessage.Text = ee.Message;
}
finally
{
//dCmd.Dispose();
conn.Close();
conn.Dispose();
}
}
protected void DeleteRecord(object sender, GridViewDeleteEventArgs e)
{
string autoid = GridView1.DataKeys[e.RowIndex].Value.ToString();
//SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ToString());
SqlCommand dCmd = new SqlCommand();
try
{
LinkButton lnkbtn = sender as LinkButton;
//getting particular row linkbutton
// GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
//getting userid of particular row
// int userid = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
// string username = gvrow.Cells[0].Text;
conn.Open();
SqlCommand cmd = new SqlCommand("delete from myTable where AutoID=" + autoid, conn);
int result = cmd.ExecuteNonQuery();
conn.Close();
if (result == 1)
{
BindData();
//Displaying alert message after successfully deletion of user
//ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + PackageName + " details deleted successfully')", true);
//GridView1.DataSourceID = null;
//GridView1.DataSourceID = "SqlDataSource1";
}
//dCmd.CommandText = "spDeleteData";
//dCmd.CommandType = CommandType.StoredProcedure;
//dCmd.Parameters.Add("@AutoID", SqlDbType.Int).Value = Int32.Parse(autoid);
//dCmd.Connection = conn;
//dCmd.ExecuteNonQuery();
//lblMessage.Text = "Record Deleted successfully.";
// Refresh the data
BindData();
}
catch (SqlException ee)
{
lblMessage.Text = ee.Message;
}
finally
{
dCmd.Dispose();
conn.Close();
conn.Dispose();
}
}
}
USE [sqlcon]
GO
/****** Object: Table [dbo].[myTable] Script Date: 12/08/2012 10:08:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[myTable](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[PageName] [varchar](50) NULL,
[PageDescription] [varchar](500) NULL,
[Active] [bit] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
Stored Procedure :
USE [sqlcon]
GO
/****** Object: StoredProcedure [dbo].[spUpdateData] Script Date: 12/08/2012 10:09:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spUpdateData]
@AutoID [int],
@PageName [varchar](50),
@PageDescription [varchar](500),
@Active [Bit]
AS
UPDATE myTable
SET PageName=@PageName,
PageDescription=@PageDescription ,
Active=@Active
WHERE AutoID=@AutoID
IN ASPX-Page :
<form id="form1" runat="server">
<div>
<asp:Label ID="lblMessage" runat="Server" ForeColor="Red"></asp:Label>
<asp:GridView ID="GridView1" runat="Server" AutoGenerateColumns="False" BorderWidth="1"
DataKeyNames="AutoID" AutoGenerateEditButton="True" OnRowEditing="EditRecord"
OnRowCancelingEdit="CancelRecord" OnRowUpdating="UpdateRecord" CellPadding="4"
HeaderStyle-HorizontalAlign="left" OnRowDeleting="DeleteRecord" RowStyle-VerticalAlign="Top"
ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundField DataField="AutoID" HeaderText="AutoID" ReadOnly="True" />
<asp:TemplateField HeaderText="Page Name">
<ItemTemplate>
<%# Eval("PageName") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPageName" runat="Server" Text='<%# Eval("PageName") %>' Columns="30"></asp:TextBox>
<asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtPageName"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Page Description">
<ItemTemplate>
<%# Eval("PageDescription") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPageDesc" runat="Server" TextMode="MultiLine" Rows="10" Columns="50"
Text='<%# Eval("PageDescription") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="req2" runat="Server" Text="*" ControlToValidate="txtPageDesc"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<%# Eval("Active") %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropActive" runat="server" SelectedValue='<%# Eval("Active").ToString().ToLower().Equals("true") ? "True" : "False" %>'>
<asp:ListItem Text="Yes" Value="True"></asp:ListItem>
<asp:ListItem Text="No" Value="False"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<span onclick="return confirm('Are you sure to Delete the record?')">
<asp:LinkButton ID="lnkB" runat="Server" Text="Delete" CommandName="Delete"></asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" VerticalAlign="Top" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
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.Web.Configuration;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class samplegrid : System.Web.UI.Page
{
static string connStr = ConfigurationManager.ConnectionStrings["reg"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
SqlDataAdapter dAd = new SqlDataAdapter("select * from myTable", conn);
DataSet dSet = new DataSet();
try
{
dAd.Fill(dSet, "PagesData");
GridView1.DataSource = dSet.Tables["PagesData"].DefaultView;
GridView1.DataBind();
}
catch (Exception ee)
{
lblMessage.Text = ee.Message.ToString();
}
finally
{
dSet.Dispose();
dAd.Dispose();
conn.Close();
conn.Dispose();
}
}
protected void EditRecord(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindData();
}
protected void CancelRecord(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindData();
}
protected void UpdateRecord(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
int autoid = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
TextBox tPageName = (TextBox)row.FindControl("txtPageName");
TextBox tPageDesc = (TextBox)row.FindControl("txtPageDesc");
DropDownList dActive = (DropDownList)row.FindControl("dropActive");
//SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ToString());
SqlCommand dCmd = new SqlCommand();
try
{
conn.Open();
dCmd.CommandText = "spUpdateData";
dCmd.CommandType = CommandType.StoredProcedure;
dCmd.Parameters.Add("@AutoID", SqlDbType.Int).Value = autoid;
dCmd.Parameters.Add("@PageName", SqlDbType.VarChar, 50).Value = tPageName.Text.Trim();
dCmd.Parameters.Add("@PageDescription", SqlDbType.VarChar, 500).Value = tPageDesc.Text.Trim();
dCmd.Parameters.Add("@Active", SqlDbType.Bit).Value = bool.Parse(dActive.SelectedValue);
dCmd.Connection = conn;
dCmd.ExecuteNonQuery();
//conn.Open();
//SqlCommand cmd = new SqlCommand("update myTable SET PageName='"+tPageName.Text+"',PageDescription='"+tPageDesc.Text+"',Active='"+dActive.SelectedValue+"' where AutoID='"+autoid+"'", conn);
//int result = cmd.ExecuteNonQuery();
//conn.Close();
//if (result == 1)
//{
// BindData();
//}
//lblMessage.Text = "Record Updated successfully.";
// Refresh the data
GridView1.EditIndex = -1;
BindData();
}
catch (SqlException ee)
{
lblMessage.Text = ee.Message;
}
finally
{
//dCmd.Dispose();
conn.Close();
conn.Dispose();
}
}
protected void DeleteRecord(object sender, GridViewDeleteEventArgs e)
{
string autoid = GridView1.DataKeys[e.RowIndex].Value.ToString();
//SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ToString());
SqlCommand dCmd = new SqlCommand();
try
{
LinkButton lnkbtn = sender as LinkButton;
//getting particular row linkbutton
// GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
//getting userid of particular row
// int userid = Convert.ToInt32(GridView1.DataKeys[gvrow.RowIndex].Value.ToString());
// string username = gvrow.Cells[0].Text;
conn.Open();
SqlCommand cmd = new SqlCommand("delete from myTable where AutoID=" + autoid, conn);
int result = cmd.ExecuteNonQuery();
conn.Close();
if (result == 1)
{
BindData();
//Displaying alert message after successfully deletion of user
//ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + PackageName + " details deleted successfully')", true);
//GridView1.DataSourceID = null;
//GridView1.DataSourceID = "SqlDataSource1";
}
//dCmd.CommandText = "spDeleteData";
//dCmd.CommandType = CommandType.StoredProcedure;
//dCmd.Parameters.Add("@AutoID", SqlDbType.Int).Value = Int32.Parse(autoid);
//dCmd.Connection = conn;
//dCmd.ExecuteNonQuery();
//lblMessage.Text = "Record Deleted successfully.";
// Refresh the data
BindData();
}
catch (SqlException ee)
{
lblMessage.Text = ee.Message;
}
finally
{
dCmd.Dispose();
conn.Close();
conn.Dispose();
}
}
}
Thursday, 6 December 2012
Android App - Display all the contents which the user given
in Xml-Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="submit" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="submit" />
</LinearLayout>
src->mainactivity.java
package com.example.sathya;
import com.example.sathya.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Button;
import android.view.*;
public class SathyaMainActivity extends Activity {
private EditText edittext;
private TextView text;
private Button but;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sathya_main);
addKeyListener();
}
public void addKeyListener()
{
edittext = (EditText) findViewById(R.id.editText);
text = (TextView) findViewById(R.id.textView1);
but=(Button) findViewById(R.id.button1);
but.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
text.setText(edittext.getText().toString());
}
});
}
}
Output:
Subscribe to:
Posts (Atom)
















