Thursday, July 25, 2013
Thursday, May 16, 2013
Jquery Game - Snake and Ladder
http://snakeandladders.net/
Please click here to play
Jquery snake and ladder game. Only jquery and html is used.
Play and add your comment on this post.
Please click here to play
Jquery snake and ladder game. Only jquery and html is used.
Play and add your comment on this post.
Tuesday, February 12, 2013
Resetting table schema Using DBCC
DBCC CHECKIDENT ('table_name', RESEED, newReseedValue)
No need to drop and create or truncate table to reset its identity.
The current identity value is set to the newReseedValue. If no rows have been inserted to the table since it was created, the first row inserted after executing DBCC CHECKIDENT will use newReseedValue as the identity. Otherwise, the next row inserted will use newReseedValue + 1. If the value of newReseedValue is less than the maximum value in the identity column, error message 2627 will be generated on subsequent references to the table.
delete from timesheet
delete from timesheetitem
dbcc checkident('timesheet',reseed,0)
dbcc checkident('timesheetitem',reseed,0)
No need to drop and create or truncate table to reset its identity.
The current identity value is set to the newReseedValue. If no rows have been inserted to the table since it was created, the first row inserted after executing DBCC CHECKIDENT will use newReseedValue as the identity. Otherwise, the next row inserted will use newReseedValue + 1. If the value of newReseedValue is less than the maximum value in the identity column, error message 2627 will be generated on subsequent references to the table.
delete from timesheet
delete from timesheetitem
dbcc checkident('timesheet',reseed,0)
dbcc checkident('timesheetitem',reseed,0)
Friday, February 1, 2013
Jquery Autocomplete in dotnet
This is a small tutorial of how to implement jquery autocomplete text box in dot net. You can try in any plat form using these steps.
First you need to download or add reference to these scripts and css.
First you need to download or add reference to these scripts and css.
<link href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"
rel="stylesheet"
type="text/css"
/>
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"
type="text/javascript"></script>
The download links for the above files are
Actually we are getting the autocomplete text as comma separated string from db,
public string
Autocomplete
{
get
{
return "c++,
java, php, coldfusion, javascript, asp, ruby";
}
}
I implemented it like a property.
And the jqery part is very simple.
$(document).ready(function () {
var tags = '<%=Autocomplete %>'; // Property from code behind
tags = tags.replace("'", ""); // Spliting the string with comma and putting it into array
var tagArray = tags.split(",");
$("#<%=txtAutocomplete.ClientID
%>").autocomplete({
source: tagArray
});
});
Simple and nice...
Wednesday, November 14, 2012
Creating a facebook app
This is a step by steb tutorial for creating a facebook app. At first you have to register as a facebook developer in https://developers.facebook.com/ , Then download the dll's FBHelper.dll and NewtoSoft.dll from this link
step:1 Navigate to https://developers.facebook.com/ and click on the app link.
step:2 click on the create new app button
step:3 Enter the app name and name space. name space is simple a name which is used to identify your app.
step 4: Complete the capche.
step:5 You will get a unique app id and app secret code. Sandboxmode should be enabled while creating and testing your app.
step 6: Open your visual studio and create an asp.net website. this is for getting your testing url.
step 7: add new page.
step 8: add the following dll's to your projects. Newtonsoft is not requered unless you are not using the direct FQL method from the FBHelper.
step 10: take your site url by running your website.
step 11: https://developers.facebook.com/ and change your canvase url. this url will be called after the user authenticate your app.
step 12: Customize your permissions.
step 13: add
using FBHelper;
using FBHelper.Entity; namespaces. then you are ready to go. see the below screen shots
Thursday, November 8, 2012
Facebook graph api
Sample application created using the following dll's
Get your blessing word https:// christopher.azurewebsites.net/
You can create a facebook application simply using these dll's.
download these dll's from the following links.
FBHelper.dll
NewtonSoft JSON
CodeProject
then you need to create a facebook app using the link fbapp and then navigate to create facebook app page and do the processings and the get the appID and appsecret.
then
Get your blessing word https://
You can create a facebook application simply using these dll's.
download these dll's from the following links.
FBHelper.dll
NewtonSoft JSON
CodeProject
then you need to create a facebook app using the link fbapp and then navigate to create facebook app page and do the processings and the get the appID and appsecret.
then
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using FBHelper;
using FBHelper.Entity;
using System.IO;
namespace FacebookApp
{
public partial class AppPage : System.Web.UI.Page
{
FB
fbApp = new FB();
protected
void Page_Load(object
sender, EventArgs e)
{
string
imageUrl = Server.MapPath(@"/image/Hydrangeas.jpg");
fbApp.AppID = "YOUR_APP_ID";
fbApp.AppSecret = "YOUR_APP_SECRET";
fbApp.RedirectURL = "http://localhost:51337/AppPage.aspx";
string
code = Request.QueryString["code"]
as string;
string
error = Request.QueryString["error_description"]
as string;
if
(string.IsNullOrEmpty(error))
{
if
(string.IsNullOrEmpty(code))
{
Response.Redirect(fbApp.CodeRequestURL);
}
else
{
fbApp.Code = code;
fbApp.GetAccessToken();
string
token = fbApp.AccessToken;
FBUser
user = fbApp.GetMe();
List<FBUser> friends = fbApp.GetMyFriends();
List<Photo> pics = fbApp.GetMyPhotos();
string
statusID = fbApp.UpdateStatus(user.ID, "hiiiii");
string
album = fbApp.CreateAlbum(user.ID, "Sample",
"new sample");
List<Album> alb = fbApp.GetAllAlbumDetails();
List<Likes> like = fbApp.GetAllLikesByMe();
fbApp.UploadPhoto("Sample Image", imageUrl);
fbApp.UploadPhotoToAnAlbum(album, "Hiiiiii",
imageUrl);
}
}
}
}
}
Facebook direct fql query using c#
CodeProject
first you should check the permisson on facebook https://developers.facebook.com/docs/reference/login/user-friend-permissions/
string query= "select
aid,name,cover_pid,created,modified,description from album where
owner=me()";
string data = string.Empty;
Uri uri = new Uri("https://graph.facebook.com
fql?q=" + query + "&access_token="
+ accessToken);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method
= "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = (Stream)response.GetResponseStream();
StreamReader reader = new
StreamReader(stream);
data = reader.ReadToEnd();Facebook get all album
CodeProject
first you should check the permisson on facebook
https://developers.facebook.com/docs/reference/login/user-friend-permissions/
string data = string.Empty;
Uri uri = new Uri("https://graph.facebook.com/me/albums?access_token=" + token);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method
= "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = (Stream)response.GetResponseStream();
StreamReader reader = new
StreamReader(stream);
data
= reader.ReadToEnd();
Facebook get all photos
first you should check the permisson on facebook https://developers.facebook.com/docs/reference/login/user-friend-permissions/
CodeProject
CodeProject
string data = string.Empty;
Uri uri = new Uri("https://graph.facebook.com/me/photos?access_token=" + token);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method
= "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = (Stream)response.GetResponseStream();
StreamReader reader = new
StreamReader(stream);
data
= reader.ReadToEnd();
Facebook get all friends
frist you should check the permisson on facebook https://developers.facebook.com/docs/reference/login/user-friend-permissions/
string data = string.Empty;
Uri uri = new Uri("https://graph.facebook.com/
me/friends?access_token=" + token);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method
= "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = (Stream)response.GetResponseStream();
StreamReader reader = new
StreamReader(stream);
data
= reader.ReadToEnd();
Facebook Get loggedin user details using c#
CodeProject
string data = string.Empty;
Uri uri = new Uri("https://graph.facebook.com/me?access_token="
+ token);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method
= "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = (Stream)response.GetResponseStream();
StreamReader reader = new
StreamReader(stream);
data
= reader.ReadToEnd();
Facebook Upload Photo using c#
You can either create one album and upload to the album, otherwise you can upload to the default album of your app.
In order to publish a photo to a user’s album, you must have the
CodeProject
In order to publish a photo to a user’s album, you must have the
publish_stream
permission. With that granted, you can upload a photo by issuing an
HTTP POST request with the photo content and an optional description to
one these to Graph API connections:
-
https://graph.facebook.com/USER_ID/photos- The photo will be published to an album created for your app. We automatically create an album for your app if it does not already exist. All photos uploaded this way will then be added to this same album.
-
https://graph.facebook.com/ALBUM_ID/photos- The photo will be published to a specific, existing photo album, represented by the ALBUM_ID.
CodeProject
WebClient client = new WebClient();
client.UploadFile("https://graph.facebook.com/me/photos?access_token="
+ accessToken + "&message=" +
name, "POST", path);
upload to the particular album
WebClient client = new WebClient();
client.UploadFile("https://graph.facebook.com/" + albumID
+ "/photos?access_token=" +
accessToken + "&message=" +
name, "POST", path);
Tuesday, September 25, 2012
Disable Right Click In a Web Page
We can disable right click on apage using the following code
<script type="text/javascript">
document.onmousedown = clickfn;
function clickfn(e) {
var button;
if (navigator.appName == "Microsoft Internet Explorer") {
button = event.button;
}
else {
button = e.buttons;
}
if (button == 2) {
alert("Right Click Disabled");
if (navigator.appName == "Microsoft Internet Explorer") {
event.returnValue = false;
}
return false;
}
}
</script>
navigator.appName == "Microsoft Internet Explorer" this is used because in ie 7 "e" is not supported so we used event in common for all ie versions...
<script type="text/javascript">
document.onmousedown = clickfn;
function clickfn(e) {
var button;
if (navigator.appName == "Microsoft Internet Explorer") {
button = event.button;
}
else {
button = e.buttons;
}
if (button == 2) {
alert("Right Click Disabled");
if (navigator.appName == "Microsoft Internet Explorer") {
event.returnValue = false;
}
return false;
}
}
</script>
navigator.appName == "Microsoft Internet Explorer" this is used because in ie 7 "e" is not supported so we used event in common for all ie versions...
Wednesday, September 5, 2012
$.ajax Method - Asynchronous postback
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'jisha','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
data: "{'data':'jisha','value1':'123456'}" - the data is the parameter needed for the method.
here "data" and "value1" are the parameter names - should be same as the code behind parameter name.
each $.ajax function needs a post back. so total 5 post backs in the button btn click.
try and feel... lol..............
Look at the below button click function, i ve 5 post backs. bt the user does not feel even one.
Ajax made it all happen.
html code
*****************************************************************************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sample.aspx.cs" Inherits="sample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=txt.ClientID %>").keypress(function (e) {
if (e.charCode == 44 || e.which == 44) {
if ($.browser.msie)
event.returnValue = false;
return false;
}
});
$("#<%=btn.ClientID %>").click(function () {
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'chris','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'sonu','value1':'123456a'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
},
error: function (msg) {
alert(msg.responseText);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'golda','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'jisha','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'ramees','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
return false;
});
});
function suc(msg) {
var text = $("#divBody").html();
$("#divBody").html(text + "<br/>" + msg.d);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="scr" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<div>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="Click" />
</div>
<div id="divBody"></div>
</form>
</body>
</html>
*****************************************************************************
Code behind
*****************************************************************************
using System;
using System.Web.Services;
public partial class sample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string ShowValue(string data, int value1)
{
return DateTime.Now.ToString() + " " + data + " " + value1;
}
}
*****************************************************************************
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'jisha','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
data: "{'data':'jisha','value1':'123456'}" - the data is the parameter needed for the method.
here "data" and "value1" are the parameter names - should be same as the code behind parameter name.
each $.ajax function needs a post back. so total 5 post backs in the button btn click.
try and feel... lol..............
Look at the below button click function, i ve 5 post backs. bt the user does not feel even one.
Ajax made it all happen.
html code
*****************************************************************************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sample.aspx.cs" Inherits="sample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=txt.ClientID %>").keypress(function (e) {
if (e.charCode == 44 || e.which == 44) {
if ($.browser.msie)
event.returnValue = false;
return false;
}
});
$("#<%=btn.ClientID %>").click(function () {
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'chris','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'sonu','value1':'123456a'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
},
error: function (msg) {
alert(msg.responseText);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'golda','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'jisha','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
$.ajax({
type: "POST",
url: "sample.aspx/ShowValue",
data: "{'data':'ramees','value1':'123456'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function (msg) {
suc(msg);
}
});
return false;
});
});
function suc(msg) {
var text = $("#divBody").html();
$("#divBody").html(text + "<br/>" + msg.d);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="scr" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<div>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="Click" />
</div>
<div id="divBody"></div>
</form>
</body>
</html>
*****************************************************************************
Code behind
*****************************************************************************
using System;
using System.Web.Services;
public partial class sample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string ShowValue(string data, int value1)
{
return DateTime.Now.ToString() + " " + data + " " + value1;
}
}
*****************************************************************************
Subscribe to:
Posts (Atom)


