Saturday, 27 July 2013

How to Create the SQL Stored Procedure


Open the SQL server 2005 or 2008 and then create a database and the tables and add the fields as your requirement.Here in this example I use two fields.

ID  int
Name  Varchar(50)

Now Click the New query and the Type following Stored Procedure :

USE [DBNAME]

GO

CREATE procedure Sp_Tblname
@ID int=0,
@Name varchar(50)=null,
@Mode varchar(100)=null
as
begin

if @Mode='Insert'
Insert into Tblname(Name) values (@Name)
end

if @Mode='Update'
begin
update Tblname set Name=@Name where ID=@ID
end

if @Mode='Delete'
begin
Delete from Tblname where ID=@ID
end

if @Mode='Selectall'
begin
Select * from Tblname
end

end

This is the simple stored procedure created using sql.After completing it u can Execute it.
After this u can call these parameters and stored procedure as shown in this link http://sathyadotnet.blogspot.in/search/label/3-Tier%20Architecture.

Thursday, 25 July 2013

How To Back Up Complete BLOG and Template



Here the Entire BLOG can be back up through Google takeout(https://www.google.com/takeout/#custom) and also directly from your BLOG.First I tell you how to back up using Google takeout and then from the blog directly.

Back up Blog using Google TakeOut:

1, Login to https://www.google.com/takeout/#custom using your respective blog account.

2, After that Click Choose services and then in the Select service choose Blooger

3, Select the “Create Archive” button.
4, Once the progress bar reaches 100%,Click Download(It automatically compress the file and start downloading)

5,Thats it!!! YOUR BLOG BACK UP GETS OVER.

Back up Blog directly from your Blog:
1, Open your blog and then Sign In
2, Then go to Settings from Design or Dashboard.
3, Click the Other options from Settings tab.

4, Look at the Blog Tools: Import Blog - Export Blog - Delete Blog.
5, Hit on the Export Blog.

6, Now click Download Blog.

7, Save the .xml file in your hard disk.

Then If you wanna restore your blog from that previously saved copy then follow the above steps again. Just in the step 5 you have to Choose Import Blog. Then choose and upload the .xml file that you've saved in your hard disk...

Back up your Blog Template:
1, Open your blog and then Sign In
2, Then go to Template from Design or Dashboard.
3, Now Click Backup/Restore at the top right as shown
4, Then click the Download the template and save it in XML format.


If you want to Upload that saved file follow the same but at Step4 click the choose file and then click Upload.


Friday, 19 July 2013

ADD SMOOTH BACK TO TOP BUTTON FOR BLOGGER

If you have lot of contents in your blog pages, and if you want to make your blog to be easy to navigate for your readers, a back to top button will make it easy and perfect....

Step 1: Log on your blogger account and Go to, Dashboard > Template > Edit html.

Step 2: Find the following tag by using "Ctrl + F".

]]></b:skin> 


Step 3: Copy and Paste below code before the above tag.

#backtotop {
padding:5px;
position:fixed;
bottom: 5px;
right: 5px;
cursor:pointer;
}


Step 4: Find the </body> tag by using "Ctrl + F" and copy and paste below code before the </body> tag.

<a href="#" id="backtotop"><img src="Image Url" alt="back to top" /></a>

Step 5: Now select your free back to top button in the below list and copy and paste it’s Image URL in to the place of "Image Url" of above code.



 

1. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgd9SBqUcL5aZc2asOck9bGTQUljlDnAThyphenhyphen5nuBvnEdK27kjZWD5V0K14SQovGVBazmqsQJlO1aLCLYNAKTHafDphcIUmkhhRETAqV3dao-DHP4kVv8MlTL6gdyqs_1rUc4B-anA4Jm5K6/s1600/new+back+to+top+button.png

back_to_top image 
2. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUGGqzjbdtW9ZNaMhKHeomD4OPbIu-4aY83RqIyceGCiEyVvgSCRmq3TzVpaw8o89sKnLibU8vjm9wN1q14CFM_55ifuLfqosMpPeCh5yWelJa9gzCa_41UIAnh7PeYP-gV-jBmfhTD06g/s1600/back+to+top+button.png
back to top gadget
3. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBj6mb4yAXdzo9_iqYWxTQmdHnL9XEr9AkukO4w5DmA691Qyy6fl9pNrBgE0TZfTOB2kgV1p0qat1MfKSqjz9J8r81Qyxl3FBys4jAdxHLn0fcFzDofcKO5N-7C3JSLO55iKoSDJhnXMGw/s1600/Back_to_top_image.png

back to top classic button
4. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixFVpHm2sY0E9rB-eCKT99dJ9fLY77t_FtSzLYaov0zT_ayToftbSxg2PoCwSc1slO6RJHao_amGGdmyzwZsLz0nuRC_HDTU1Pq2t2grr5Y96GJTDcp9KP4MoJwuw6rC0_udu7IgAGs7Hj/s1600/back_to_top.png


back to top

5. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii4hq1S7UVfZ1TCmqEczG9N7-vEF7Bliol20fHHPVz_iUN3TTzibiV_iMXhtfC3i5bDs-oyHITH29q361cLZ6zN-P-FG-9CJ7XIHucnMlkgGNmK8rXqoSqsOeNRDtrOZFWxDYTM4sIF-aG/s1600/back+to+top+icon.png



6. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_JijpcKQdoUgfB2HYoLLLgdLWbkKU8w7Dm6tcgFfV88UeJpcr2SZ0yMGZHH8eNfaZdj20B_l7G5zcu2zrAwq4PdiQ-GNcYBafIM7oK9VxWO_HFqa1hzhNiU8bye4_7PfYN8To7moat3fC/s1600/back_to_top_button.png

 
7. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXoMB4VH-h9x9HQQnVuNUeT36LGs1A39GIAKSgpLlF5Ijw_EB1oCvp_tqfvCbqAdIJkFWz7i9QdbWQbHGfv7R0Lti_R0MokwCcmRypqgyJh-uWUHKk8PQOBXfIwd4tARv7M4rQo97Xiyaf/s1600/back+to+top.png

back to top button
8. Image Url : https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioOyBLD_XntPDNryYCA_z3WFKl4zjtKCP_aUtHoXk5jOn46Ufg1MNMS1KnLC6af4toOfyo9ctmChC28hoO2tvLF6yBinnLHxN8Ae4jsfzh3XYKH3t7fur9xv5MCpN6NMQ00dEf7Pek2cqJ/s1600/back+to+top.png



Step 6: Find the <head> tag by using "Ctrl + F" and copy and paste below code after the <head> tag and save template..

<!-- start back to top -->
&lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js'
type='text/javascript'&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot;&gt;
$(window).ready(function(){
$('#backtotop').click(function(e){
e.preventDefault();
$('html, body').animate({scrollTop:0}, 'slow');
});
});
&lt;/script&gt;
<!-- end back to top -->

Wednesday, 17 July 2013

CSS properties


The following are the CSS properties arranged in the alphabetical order

A
align-content
align-items
align-self
animation
appearance
B
backface-visibility
background
border
border-collapse
border-image
border-radius
bottom
box-shadow
box-sizing
C
clear
clip
color
column-count
content
counter-increment
counter-reset
cursor
D
direction
display
F
flex
flex-basis
flex-direction
flex-flow
flex-grow
flex-shrink
flex-wrap
float
font
font-family
font-size
font-stretch
font-style
font-variant
font-weight
G
grid
H
hanging-punctuation
height
hyphens
J
justify-content
L
left
letter-spacing
line-height
list-style
M
margin
max-height
max-width
min-height
min-width
O
opacity
order
orphans
outline
overflow
P
padding
page-break
perspective
perspective-origin
pointer-events
position
Q
quotes
R
resize
right
S
scrollbar
T
tab-size
text-align
text-decoration
text-indent
text-overflow
text-shadow
text-stroke
top
transform
transform-origin
transform-style
transition
U
unicode-bidi
user-select
V
vertical-align
visibility
W
white-space
widows
width
word-break
word-spacing
Z
z-index
zoom

Box/DIV Shadows using CSS

Apply the following CSS for the shadow effect in the DIV's

.shadowdiv
{

-webkit-box-shadow: 0 0 5px 2px #000;
-moz-box-shadow: 0 0 5px 2px #000;
box-shadow: 0 0 5px 2px #000;

}
1st 0 is the horizontal offset of the shadow,this 0 will give shadow on both the left and right side of the div,Positive value like 2px will give shadow on right side and Negative value like -2px will give shadow on left side.

2nd 0 is the vertival offset of the shadow,this 0 will give shadow on both the top and bottom of the div,Positive value like 2px will give shadow on below and Negative value like -2px will give shadow on top.
  
5px is for the blur of the shadow.Higher the value,higher the Blurness.0 will give sharp shadow.  

2px is for spread radius or thickness of the shadow.positive increase the size and negative decrease size.

#000 is the color of the shadow.We can change to any color as required.

<html>
<head>
<style type="text/css">

.shadowdiv
{

width:200px;
height:200px; 
-webkit-box-shadow: 0 0 5px 2px #000;
-moz-box-shadow: 0 0 5px 2px #000;
box-shadow: 0 0 5px 2px #000;

}

</style>
</head>
<body>

<div class="shadowdiv">
Hi,This is an example div for the box shadow
<div> 

</body>
</html>

Tuesday, 16 July 2013

Extract Characters using Substring in SQL

Substring in SQL will Extract the characters from an starting point of the strings in the column name of the database.The syntax for it is

SUBSTRING(string or column name, startIndex, length)
string denotes the columnname or the string value
start index denotes the starting point from where extraction begins
length denotes the how many characters to be extracted.

Example Select query using substring:
SELECT SUBSTRING(Names,2,3) as 'substring' FROM TABLENAME
This query will return Names starting from 3 and return 3 characters from the strings in that columname. 

Monday, 15 July 2013

How to use Substring in Asp.net C#


The Substring method is used to extract the characters from any part of the string.The syntax is

Substring( start_position, num_of_chars_to_grab )

Example:

Substring(0,2)
0 is the starting index of the string
2 is the length or number of characters to be grab or extract.

Example to extract characters form a string using Textbox,Label and Button.

protected void Button1_Click(object sender, EventArgs e)

{

string a = TextBox1.Text.ToString();

string b = a.Substring(2, 2); //Extract 2 characters start from the 2 index position

Label1.Text = b.ToString();

}

Friday, 5 July 2013

Delete Confirmation box in the asp.net Grid view

Create a page with the gridview in the .aspx page as below

<html>
<head runat="server">

<script type="text/javascript">

function ConfirmationBox(Name) {

var result = confirm('Do you want to delete '+ Name +' Details' );

if (result) {

return true;
}

else {

return false;
}
}
</script>

</head>

<body>

<form id="form1" runat="server">
<div>

<asp:gridview autogeneratecolumns="false" datakeynames="Uid" id="deletegrid" onrowdatabound="deletegrid_RowDataBound" runat="server">

<columns>

<asp:boundfield datafield="Name" headertext="Name"/>
<asp:boundfield datafield="Mobile" headertext="Mobile"/>
<asp:boundfield datafield="Full Name" headertext="Fullname"/>

<asp:templatefield headertext="Delete"/>

<itemtemplate>

<asp:linkbutton id="deltlnkbtn" onclick="deltlnkbtn_Click" runat="server">
Delete User</asp:linkbutton>

</itemtemplate>

</asp:templatefield>

</columns>

</asp:gridview>

</div>
</form>
</body>
</html>
Now enter the following code in the .aspx.cs code behind as
SqlConnection con = new SqlConnection("Data Source=localhostname;Integrated Security=true;Initial Catalog=DBname");

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

BindUser();

}
}

protected void BindUser()
{
//connection open
con.Open();

//sql command to execute query from database
SqlCommand cmd = new SqlCommand("Select * from tablename",con);

cmd.ExecuteNonQuery();

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds);

//Bind data to gridview
deletegrid.DataSource = ds;
deletegrid.DataBind();

con.Close();
}
protected void deletegrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//get the name from a row
string Name =Convert.ToString(DataBinder.Eval(e.Row.DataItem,"Name"));

//identifying the control in gridview
LinkButton lnkbtns = (LinkButton)e.Row.FindControl("deltlnkbtn");

//raising javascript confirmationbox while clicking the link button
lnkbtns.Attributes.Add("onclick", "javascript:return ConfirmationBox('" + Name + "')");
}
}

protected void deltlnkbtn_Click(object sender, EventArgs e)
{

LinkButton lnkbtn= sender as LinkButton;

//get the particular row linkbutton
GridViewRow delgvrow = lnkbtn.NamingContainer as GridViewRow;

//get the userid of particular row
int userid = Convert.ToInt32(deletegrid.DataKeys[delgvrow.RowIndex].Value.ToString());

string Name = gvrow.Cells[0].Text;

con.Open();
SqlCommand cmd = new SqlCommand("delete from UserDetails where Uid="+Uid,con);

int temp=cmd.ExecuteNonQuery();

con.Close();

if (temp == 1)
{

BindUser();

//Displaying alert message after successfully deletion of user
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + Name + " deleted successfully')", true);
}
}

Monday, 1 July 2013

Flying Image from one cart to another

<html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <!-- Script for flying image --> <script type="text/javascript"> $(document).ready(function(){ $(".productPriceWrapRight a img").click(function() { var productIDValSplitter = (this.id).split("_"); var productIDVal = productIDValSplitter[1]; var productX = $("#productImageWrapID_" + productIDVal).offset().left; var productY = $("#productImageWrapID_" + productIDVal).offset().top; var basketX = $("#basketTitleWrap").offset().left; var basketY = $("#basketTitleWrap").offset().top; var gotoX = basketX - productX; var gotoY = basketY - productY; var newImageWidth = $("#productImageWrapID_" + productIDVal).width() / 3; var newImageHeight = $("#productImageWrapID_" + productIDVal).height() / 3; $("#productImageWrapID_" + productIDVal + " img") .clone() .prependTo("#productImageWrapID_" + productIDVal) .css({'position' : 'absolute','border-width':'5px','border-color':'red','border-style':'dotted'} .animate({opacity: 0.5}, 100 ) .animate({opacity: 0.2, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 1200, function() {   $(this).remove(); }); }); });
</script> </head> <body> <form id="form1" runat="server"> <div> <!-- Datalist can also be used --> <!-- add images in the gridview dynamicaly from the database --> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" > <Columns> <asp:TemplateField  HeaderText="Model"><ItemTemplate> <div class="productImageWrap" id="productImageWrapID_<%# Eval("ID") %>"> <img src = '<%# "Handler.ashx?ID= " + Eval ("ID") %> ' id = "img" /> </div> </ItemTemplate> </asp:TemplateField> <asp:TemplateField  HeaderText="Model"> <ItemTemplate> <div class="productPriceWrapRight"> <!-- a href tag can also be used --> <asp:LinkButton ID="a" CommandName="select" runat="server"> <img src="images/add-to-basket2.gif" alt="Add To Basket" width="111" height="32"id="featuredProduct_<%# Eval("ID") %>" /> </asp:LinkButton> </div> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </div> <div> <div id="basketTitleWrap"> Your Basket </div> </div> </form> </body> </html>
back to top