http://www.siphilp.co.uk/archive/2007/11/08/adding-a-javascript-onclick-event-to-a-radio-button-list.aspx
Rad-Combobox databind at Clientside using javascript
http://www.telerik.com/community/forums/aspnet-ajax/combobox/rad-combobox-databind-at-clientside-using-javascript.aspx
JavaScript Split String Function
http://programming.top54u.com/Samples/Javascript/String-Object/Split-String-Function/Default.aspx
28.12.10
25.12.10
rotate images
http://fancybox.net/
http://www.huddletogether.com/projects/lightbox2/
http://www.efectorelativo.net/laboratory/noobSlide/
carousse:
http://www.paulvanroekel.nl/picasa/caroussel/
http://demo.tutorialzine.com/2010/11/rotating-slideshow-jquery-css3/
http://www.1stwebdesigner.com/design/fresh-jquery-image-gallery-display-solutions/
http://www.huddletogether.com/projects/lightbox2/
http://www.efectorelativo.net/laboratory/noobSlide/
carousse:
http://www.paulvanroekel.nl/picasa/caroussel/
http://demo.tutorialzine.com/2010/11/rotating-slideshow-jquery-css3/
http://www.1stwebdesigner.com/design/fresh-jquery-image-gallery-display-solutions/
22.12.10
jquery zoom and Thumbnail rotate
http://leandrovieira.com/projects/jquery/lightbox/#
http://www.javascriptphotogallery.com/jquery-image-gallery-zoom-asp-net.html
http://www.professorcloud.com/mainsite/cloud-zoom.htm
http://www.dfc-e.com/metiers/multimedia/opensource/jquery-fancyzoom/
http://www.ajax-zoom.com/index.php?cid=home
http://jquerylightbox.com/asp-net-mvc-jquery-popup.html
http://www.dynamicdrive.com/dynamicindex4/imagemagnify.htm
http://www.dynamicdrive.com/dynamicindex4/imagemagnify.htm
http://www.ajax-zoom.com/demo/magento/index.php/ottoman.html
http://www.catosplace.net/jquery_sandbox/galleryview/index.html
http://web.enavu.com/tutorials/10-best-jquery-gallery-and-slider-plugins/
http://demos.telerik.com/aspnet-ajax/rotator/examples/gallery/defaultcs.aspx
http://www.javascriptphotogallery.com/jquery-image-gallery-zoom-asp-net.html
http://www.professorcloud.com/mainsite/cloud-zoom.htm
http://www.dfc-e.com/metiers/multimedia/opensource/jquery-fancyzoom/
http://www.ajax-zoom.com/index.php?cid=home
http://jquerylightbox.com/asp-net-mvc-jquery-popup.html
http://www.dynamicdrive.com/dynamicindex4/imagemagnify.htm
http://www.dynamicdrive.com/dynamicindex4/imagemagnify.htm
http://www.ajax-zoom.com/demo/magento/index.php/ottoman.html
http://www.catosplace.net/jquery_sandbox/galleryview/index.html
http://web.enavu.com/tutorials/10-best-jquery-gallery-and-slider-plugins/
http://demos.telerik.com/aspnet-ajax/rotator/examples/gallery/defaultcs.aspx
13.12.10
12.12.10
Dynamically Output A List of YouTube Videos In ASP.NET
http://surinder.computing-studio.com/post/2009/05/Dynamically-Output-A-List-of-YouTube-Videos-In-ASPNET.aspx
AI39si50OOMnhiZKAqaYo9EaxOH900UCbvwkGbUVDhfxuOjFEg7wR2gC8nXsoZuc_MfHvBznmrzL5Qn-L30AA6jKkXL6IKoANA
http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html
AI39si50OOMnhiZKAqaYo9EaxOH900UCbvwkGbUVDhfxuOjFEg7wR2gC8nXsoZuc_MfHvBznmrzL5Qn-L30AA6jKkXL6IKoANA
http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html
1.11.10
31.10.10
Download PDF,DOC file from Radgrid .
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/gridattachmentcolumn/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grdconditionalimagedisplayingridcolumn.html
http://www.longhorncorner.com/UploadFile/prathore/3091/Default.aspx
http://aspalliance.com/259
http://www.telerik.com/help/aspnet-ajax/grdconditionalimagedisplayingridcolumn.html
http://www.longhorncorner.com/UploadFile/prathore/3091/Default.aspx
http://aspalliance.com/259
29.8.10
OnKeyUp Of Textbox inside Ajaxpanel
OnKeyUp Of Textbox inside Ajaxpanelhttp://tastyrazors.com/?p=10
http://forums.asp.net/t/1304375.aspx
http://forums.asp.net/t/1100070.aspx
Disable update Panel of Master Page:
http://forums.asp.net/t/1304375.aspx
http://forums.asp.net/t/1304375.aspx
http://forums.asp.net/t/1100070.aspx
Disable update Panel of Master Page:
http://forums.asp.net/t/1304375.aspx
21.8.10
Call Server Side function from Client Side Code using PageMethods in ASP.NET AJAX
http://fei29.blogspot.com/2010/02/call-server-side-function-from-client.html
Check gridview header checkbox if all item checkbox are checked
<script language="javascript" type="text/javascript">
<!--
function ChangeCheckBoxState(id, checkState) {
var cb = document.getElementById(id);
if (cb != null)
cb.checked = checkState;
}
function ChangeAllCheckBoxStates(checkState) {
// Toggles through all of the checkboxes defined in the CheckBoxIDs array
// and updates their value to the checkState input parameter
if (CheckBoxIDs != null) {
for (var i = 0; i < CheckBoxIDs.length; i++)
ChangeCheckBoxState(CheckBoxIDs[i], checkState);
}
}
function ChangeHeaderAsNeeded() {
// Whenever a checkbox in the GridView is toggled, we need to
// check the Header checkbox if ALL of the GridView checkboxes are
// checked, and uncheck it otherwise
if (CheckBoxIDs != null) {
// check to see if all other checkboxes are checked
for (var i = 1; i < CheckBoxIDs.length; i++) {
var cb = document.getElementById(CheckBoxIDs[i]);
if (!cb.checked) {
// Whoops, there is an unchecked checkbox, make sure
// that the header checkbox is unchecked
ChangeCheckBoxState(CheckBoxIDs[0], false);
return;
}
}
// If we reach here, ALL GridView checkboxes are checked
ChangeCheckBoxState(CheckBoxIDs[0], true);
}
}
-->
</script>
protected void grdStudents_DataBound(object sender, EventArgs e)
{
if (grdStudents.Rows.Count > 0)
{
CheckBox cbHeader = (CheckBox)grdStudents.HeaderRow.FindControl("HeaderLevelCheckBox");
cbHeader.Attributes["onclick"] = "ChangeAllCheckBoxStates(this.checked);";
List<String> ArrayValues = new List<string>();
ArrayValues.Add(String.Concat("'", cbHeader.ClientID, "'"));
foreach (GridViewRow gvr in grdStudents.Rows)
{
CheckBox cb = (CheckBox)gvr.FindControl("chkSelect");
cb.Attributes["onclick"] = "ChangeHeaderAsNeeded();";
ArrayValues.Add(String.Concat("'", cb.ClientID, "'"));
}
CheckBoxIDsArray.Text = @"<script type=""text/javascript"">" + "\r\n" +
"<!--" + "\r\n" +
String.Concat("var CheckBoxIDs = new Array(", String.Join(",", ArrayValues.ToArray()), ");") + "\r\n" +
"// -->" + "\r\n" +
"</script>";
}
}
HTML fieldset
<tr>
<td class="field" style="width: 582px">
<fieldset style="background-color: #F8F3E3;">
<legend>
<asp:Label ID="lblStudentManagement" runat="server" CssClass="labelTextBold">Management</asp:Label>
</legend>
<table border="0" align="center" cellpadding="0" cellspacing="5" style="width: 582px;
height: 186px">
<tr>
<td style="width: 8%">
</td>
<td class="txt_color" style="width: 59%" valign="top">
<ul class="listmenu">
<li><a href="Enroll.aspx" target="_self">Enrol</a></li>
<li><a href="List.aspx">List</a></li>
</ul>
</td>
<td valign="top">
<br />
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
8.8.10
find text in all sp of a particular sql database.
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%Reassign%'
AND ROUTINE_TYPE='PROCEDURE'
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%Reassign%'
AND ROUTINE_TYPE='PROCEDURE'
4.8.10
User not to enter Numberor Decimal in textbox..
By AJAX:
http://forums.asp.net/p/1288474/3802854.aspx
-------------
1.How to check if a textbox contains a number
http://bytes.com/topic/asp-net/insights/654366-how-check-if-textbox-contains-number
2. check user not enter decimal value in textbox
3.) If textbox contain No number then Blank it.
4.) Confirmation on button click
btnSave.Attributes["OnClick"] = "javascript:return confirmation();";
http://forums.asp.net/p/1288474/3802854.aspx
-------------
1.How to check if a textbox contains a number
http://bytes.com/topic/asp-net/insights/654366-how-check-if-textbox-contains-number
2. check user not enter decimal value in textbox
txtCourseFee.Attributes["OnKeyPress"] = "javascript:CheckDecimal(event);";
function CheckDecimal(event) {
var isNS4 = (navigator.appName == "Netscape") ? 1 : 0;
if (!isNS4) {
if (event.keyCode < 46 || event.keyCode > 57)
event.returnValue = false;
}
else {
if (event.which < 46 || event.which > 57) return false;
}
}
3.) If textbox contain No number then Blank it.
txtCourseFee.Attributes["onblur"] = "javascript:isNotNumberThenBlank(" + txtCourseFee.ClientID + ");";
function isNotNumberThenBlank1(obj) {
if (obj.value.search(/[^0-9^.^ ]/) != -1) {
obj.value = "";
obj.focus();
alert('Please enter only numeric value');
return false;
}
return true;
}
4.) Confirmation on button click
btnSave.Attributes["OnClick"] = "javascript:return confirmation();";
function ConfirmSave() {
var retVal = confirm("This will save Student information. Do you want to continue ?");
return retVal;
}
DropDown list Inside GridView
1.DropDown list Inside GridView
http://www.dotnetspider.com/resources/26560-DropDown-List-inside-Gridview.aspx
2.Dropdownlist in gridview footer
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_23238330.html
http://www.dotnetspider.com/resources/26560-DropDown-List-inside-Gridview.aspx
2.Dropdownlist in gridview footer
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_23238330.html
30.7.10
RadAjaxManager alert telerik
RadAjaxManager1.ResponseScripts.Add("alert('Please select atleast one Recipient')");
Execute Reader and List:
int ret = 0;
SqlCommand objCmd = new SqlCommand("UspInsertUpdate_DashBoard", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
#region Parameters Ordte Products
objCmd.Parameters.Add("@intDashBoardId", SqlDbType.BigInt).Value = objUI.DashBoardId;
objCmd.Parameters.Add("@intUserId", SqlDbType.BigInt).Value = objUI.UserId;
objCmd.Parameters.Add("@chvnModule", SqlDbType.NVarChar).Value = objUI.Module;
objCmd.Parameters.Add("@chvnExp", SqlDbType.NVarChar).Value = objUI.Exp;
objCmd.Parameters.Add("@chvnTitle", SqlDbType.NVarChar).Value = objUI.Title;
#endregion
try
{
objCon.Open();
ret = Convert.ToInt32(objCmd.ExecuteScalar());
}
catch
{
}
finally
{
objCmd.Dispose();
objCon.Close();
}
return ret;
=====================================
list:
SqlCommand objcmd = new SqlCommand("UspDisplayAccounts", objCon);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.Add("@intUserId", SqlDbType.Int).Value = UserId;
List objList = new List();
SqlDataReader objDr;
objCon.Open();
objDr = objcmd.ExecuteReader();
try
{
while (objDr.Read())
{
Accounts objBol = new Accounts();
objBol.AccountId = Convert.ToInt32(objDr["crm_cust_info_pk"]);
objBol.Title = objDr["crm_cust_acc_title"].ToString();
objBol.CompanyName = objDr["Name"].ToString();
objBol.CreateDate = Convert.ToDateTime(objDr["crm_cust_create_date"]);
objBol.AddressId = Convert.ToInt32(objDr["crm_add_fk"]);
objBol.CreatedByName = objDr["created_by_name"].ToString();
objBol.AssignTo = objDr["assigned_to_name"].ToString();
objList.Add(objBol);
}
}
catch
{
}
finally
{
objDr.Close();
objCon.Close();
objcmd.Dispose();
}
return objList;
Execute Reader and List:
int ret = 0;
SqlCommand objCmd = new SqlCommand("UspInsertUpdate_DashBoard", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
#region Parameters Ordte Products
objCmd.Parameters.Add("@intDashBoardId", SqlDbType.BigInt).Value = objUI.DashBoardId;
objCmd.Parameters.Add("@intUserId", SqlDbType.BigInt).Value = objUI.UserId;
objCmd.Parameters.Add("@chvnModule", SqlDbType.NVarChar).Value = objUI.Module;
objCmd.Parameters.Add("@chvnExp", SqlDbType.NVarChar).Value = objUI.Exp;
objCmd.Parameters.Add("@chvnTitle", SqlDbType.NVarChar).Value = objUI.Title;
#endregion
try
{
objCon.Open();
ret = Convert.ToInt32(objCmd.ExecuteScalar());
}
catch
{
}
finally
{
objCmd.Dispose();
objCon.Close();
}
return ret;
=====================================
list:
SqlCommand objcmd = new SqlCommand("UspDisplayAccounts", objCon);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.Add("@intUserId", SqlDbType.Int).Value = UserId;
List
SqlDataReader objDr;
objCon.Open();
objDr = objcmd.ExecuteReader();
try
{
while (objDr.Read())
{
Accounts objBol = new Accounts();
objBol.AccountId = Convert.ToInt32(objDr["crm_cust_info_pk"]);
objBol.Title = objDr["crm_cust_acc_title"].ToString();
objBol.CompanyName = objDr["Name"].ToString();
objBol.CreateDate = Convert.ToDateTime(objDr["crm_cust_create_date"]);
objBol.AddressId = Convert.ToInt32(objDr["crm_add_fk"]);
objBol.CreatedByName = objDr["created_by_name"].ToString();
objBol.AssignTo = objDr["assigned_to_name"].ToString();
objList.Add(objBol);
}
}
catch
{
}
finally
{
objDr.Close();
objCon.Close();
objcmd.Dispose();
}
return objList;
Radgrid View Products aspx
Tool for write in box:http://www.accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php
<%@ Page Language="C#" AutoEventWireup="true" Theme="Admin" CodeFile="ViewProducts.aspx.cs"
Inherits="Admin_Products_ViewProducts" %>
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>
<%@ Register Src="../UserControls/HeaderBar.ascx" TagName="HeaderBar" TagPrefix="uc1" %>
<%@ Register Src="../UserControls/Footer.ascx" TagName="Footer" TagPrefix="uc2" %>
<!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>View Products</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="maincontainer">
<!--Maincontainer starts here-->
<div id="main_header">
<!--Main Header starts here-->
<uc1:HeaderBar ID="HeaderBar1" runat="server" />
</div>
<!--Main Header ends here-->
<div id="body">
<!--Body starts here-->
<div id="bodyinnerpart">
<!--Body Inner starts here-->
<div id="body_left">
<!--Body left panel starts here-->
<div id="body_leftinner">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="left" valign="middle" class="body_left_h1">
Products
</td>
</tr>
<tr>
<td class="body_left_h2" style="background-color: #FFFFFF;">
<a href="AddProducts.aspx">Add Products</a>
</td>
<td style="background-color: #FFFFFF;" class="body_left_bdr">
<img src="../images/moreicon.gif" width="7" height="13" />
</td>
</tr>
<tr>
<td width="93%" class="body_left_h2" style="background-color: #FFFFFF;">
<a href="Attributes.aspx">Add Attributes</a>
</td>
<td width="7%" style="background-color: #FFFFFF;" class="body_left_bdr">
<img src="../images/moreicon.gif" width="7" height="13" />
</td>
</tr>
<tr>
<td class="body_left_h2" style="background-color: #FFFFFF;">
<a href="AddColour.aspx">Add Colours</a>
</td>
<td style="background-color: #FFFFFF;" class="body_left_bdr">
<img src="../images/moreicon.gif" width="7" height="13" />
</td>
</tr>
</table>
</div>
<div id="body_leftinner1">
</div>
</div>
<!--Body left panel ends here-->
<div id="body_right">
<!--Body right panel starts here-->
<div id="body_right_top" class="body_right_h1">
<asp:LinkButton ID="lkparent" runat="server" Text="» Products"></asp:LinkButton>
</div>
<div id="body_right_inner1">
<table width="638" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="576" align="right" style ="padding-bottom :3px;">
<asp:TextBox ID="textsearch" runat ="server" Width="130px" ></asp:TextBox>
</td>
<td width="62" align="right" style ="padding-bottom :3px;">
<asp:ImageButton ID ="Imgsearch" runat ="server"
ImageUrl ="../images/searchbutton.gif" width="57" height="19"
onclick="Imgsearch_Click" />
</td>
</tr>
</table>
</div>
<div id="body_right_inner">
</div>
</div>
<!--Body right panel ends here-->
</div>
<!--Body Inner ends here-->
</div>
<!--Body ends here-->
<div id="footer">
<!--Footer starts here-->
<uc2:Footer ID="Footer1" runat="server" />
</div>
<!--Footer ends here-->
</div>
</div>
</form>
</body>
</html>
<radG:RadGrid ID="RadgridDisplayProducts" runat="server" Skin="WebBlue" Width="638px"
AutoGenerateColumns="False" GridLines="None" OnDeleteCommand="RadgridDisplayProducts_DeleteCommand"
OnNeedDataSource="RadgridDisplayProducts_NeedDataSource"
OnItemCommand="RadgridDisplayProducts_ItemCommand" AllowPaging="True"
EnableAJAX="True" EnableAJAXLoadingTemplate="True" PageSize="20">
<ExportSettings>
<Pdf PageWidth="8.5in" PageRightMargin="" PageFooterMargin="" PageLeftMargin="" PageTopMargin=""
PageHeight="11in" PageBottomMargin="" PageHeaderMargin=""></Pdf>
</ExportSettings>
<MasterTableView DataKeyNames="ProductsID">
<ExpandCollapseColumn Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<Columns>
<radG:GridBoundColumn DataField="Products_Name" HeaderText="Product Name" UniqueName="column">
<HeaderStyle Width="250px" />
<ItemStyle CssClass="gridtext" />
</radG:GridBoundColumn>
<radG:GridBoundColumn DataField="Model" HeaderText="Product Code" UniqueName="column">
<HeaderStyle Width="150px" />
<ItemStyle CssClass="gridtext" />
</radG:GridBoundColumn>
<radG:GridTemplateColumn>
<ItemTemplate>
<asp:ImageButton ID="Imgbtnedit" runat="server" CausesValidation="false" CommandName="View"
ImageUrl="../images/view.gif" />
</ItemTemplate>
<ItemStyle Width="120px" CssClass="gridpadding2" />
</radG:GridTemplateColumn>
<radG:GridButtonColumn ConfirmText="Delete this Record?" ButtonType="ImageButton"
ImageUrl="../images/delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"
FilterImageUrl="~/RadControls/GridSkin/Telerik/Filter.gif" SortAscImageUrl="~/RadControls/GridSkin/Telerik/SortAsc.gif"
SortDescImageUrl="~/RadControls/GridSkin/Telerik/SortDesc.gif">
<ItemStyle Width="98px" HorizontalAlign="center" />
</radG:GridButtonColumn>
</Columns>
</MasterTableView>
</radG:RadGrid>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Ecommerce.BLL;
using Ecommerce.BOL;
public partial class Admin_Products_ViewProducts : System.Web.UI.Page
{
ProductsManager objBll = new ProductsManager();
CategoriesManager objcat = new CategoriesManager();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["cid"] != null)
{
ViewState["CategoryID"] = Request.QueryString["cid"].ToString();
}
else
{
ViewState["CategoryID"] = "-1";
}
DisplayProducts();
GenrateXML();
}
}
private void GenrateXML()
{
DataSet objds = objcat.BLL_GetProductsXML();
objds.WriteXml(Server.MapPath("../../Main.xml"));
}
private void DisplayProducts()
{
RadgridDisplayProducts.DataSource = objBll.BLL_DspProducts(Convert.ToInt32(ViewState["CategoryID"]));
RadgridDisplayProducts.DataBind();
}
protected void RadgridDisplayProducts_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
if (e.CommandName == "View")
{
int PID = Convert.ToInt32(RadgridDisplayProducts.MasterTableView.DataKeyValues[e.Item.ItemIndex]["ProductsID"]);
Response.Redirect("ProductDetail.aspx?PID=" + PID.ToString());
}
}
protected void RadgridDisplayProducts_DeleteCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
int ProductsID = Convert.ToInt32(RadgridDisplayProducts.MasterTableView.DataKeyValues[e.Item.ItemIndex]["ProductsID"]);
objBll.BLL_DeleteProducts(ProductsID);
DisplayProducts();
}
protected void RadgridDisplayProducts_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
{
//RadgridDisplayProducts.DataSource = objBll.BLL_DspProducts();
RadgridDisplayProducts.DataSource = objBll.BLL_DspProducts(Convert.ToInt32(ViewState["CategoryID"]));
}
protected void Imgsearch_Click(object sender, ImageClickEventArgs e)
{
{
RadgridDisplayProducts.DataSource = objBll.BLL_ADM_ProductSearch(textsearch.Text.Trim());
RadgridDisplayProducts.DataBind();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Ecommerce.BOL;
namespace Ecommerce.DAL
{
class ProductsDB : AppConfig
{
//Insert Update Products
public int DAL_InsUpdProducts(Products objBol)
{
SqlCommand objCmd = new SqlCommand("ADM_InsUpdProductsInfo", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = objBol.ProductsID;
objCmd.Parameters.Add("@Products_Name", SqlDbType.NVarChar).Value = objBol.Products_Name;
objCmd.Parameters.Add("@Products_Description", SqlDbType.NVarChar).Value = objBol.Products_Description;
objCmd.Parameters.Add("@Meta_keywords", SqlDbType.NVarChar).Value = objBol.Meta_keywords;
objCmd.Parameters.Add("@Products_Type", SqlDbType.Int).Value = objBol.Products_Type;
objCmd.Parameters.Add("@Show_quantity", SqlDbType.Bit).Value = objBol.Show_quantity;
objCmd.Parameters.Add("@Model", SqlDbType.NVarChar).Value = objBol.Model;
objCmd.Parameters.Add("@Price", SqlDbType.Decimal).Value = objBol.Price;
objCmd.Parameters.Add("@Active", SqlDbType.Bit).Value = objBol.Active;
objCmd.Parameters.Add("@Meta_Description", SqlDbType.NVarChar).Value = objBol.Meta_Description;
objCmd.Parameters.Add("@Meta_Title", SqlDbType.NVarChar).Value = objBol.Meta_Title;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
// Insert Update Products Images
public int DAL_InsUpdProductsImages(Products objBol)
{
SqlCommand objCmd = new SqlCommand("ADM_InsUpdProductImages", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_imageID", SqlDbType.Int).Value = objBol.Products_imageID;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = objBol.ProductsID;
objCmd.Parameters.Add("@ColourID", SqlDbType.Int).Value = objBol.ColourID;
objCmd.Parameters.Add("@Icon_image", SqlDbType.VarChar).Value = objBol.Icon_image;
objCmd.Parameters.Add("@Medium_image", SqlDbType.VarChar).Value = objBol.Medium_image;
objCmd.Parameters.Add("@Large_image", SqlDbType.VarChar).Value = objBol.Large_image;
objCmd.Parameters.Add("@Colour_name", SqlDbType.VarChar).Value = objBol.Colour_name;
objCmd.Parameters.Add("@default_style", SqlDbType.Bit).Value = objBol.default_style;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
// Update Images status [ADM_UpdImagesStatus]
public int DAL_UpdImagesStatus(int ProductsID, int Products_imageID)
{
SqlCommand objCmd = new SqlCommand("ADM_UpdImagesStatus", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_imageID", SqlDbType.Int).Value =Products_imageID;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
// Insert Update Products Size Quantity
public int DAL_InsUpdProductsSize(Products objBol)
{
SqlCommand objCmd = new SqlCommand("ADM_InsUpdProductsSize", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_sizeID", SqlDbType.Int).Value = objBol.Products_sizeID;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = objBol.ProductsID;
objCmd.Parameters.Add("@attributes_values_id", SqlDbType.Int).Value = objBol.attributes_values_id;
objCmd.Parameters.Add("@attributes_values_name", SqlDbType.VarChar).Value = objBol.attributes_values_name;
objCmd.Parameters.Add("@ColourID", SqlDbType.Int).Value = objBol.ColourID;
objCmd.Parameters.Add("@Quantity", SqlDbType.Int).Value = objBol.Quantity;
objCmd.Parameters.Add("@Reorder_level", SqlDbType.Int).Value = objBol.Reorder_level;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
// Insert Update Products TO Categories
public int DAL_InsUpdProductsToCategories(Products objBol)
{
SqlCommand objCmd = new SqlCommand("ADM_InsUpdProductsToCategories", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_categoryID", SqlDbType.Int).Value = objBol.Products_categoryID;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = objBol.ProductsID;
objCmd.Parameters.Add("@CategoryID", SqlDbType.Int).Value = objBol.CategoryID;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
//---------------------------------------------------------------------------------Display Products
public ListDal_DspProducts(Int32 CategoryID)
{
SqlCommand objCmd = new SqlCommand("ADM_DspProducts", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@CategoryID", SqlDbType.BigInt).Value = CategoryID;
SqlDataReader objDr;
objCon.Open();
objDr = objCmd.ExecuteReader();
ListobjList = new List ();
if (objDr.HasRows)
{
while (objDr.Read())
{
Products objBol = new Products();
objBol.ProductsID = Convert.ToInt32(objDr["ProductsID"]);
objBol.Products_Name = objDr["Products_Name"].ToString();
objBol.Model = objDr["Model"].ToString();
objList.Add(objBol);
}
}
objDr.Close();
objCmd.Dispose();
objCon.Close();
return objList;
}
//Display Products By ID
public ListDal_DspProductsBYID(Int32 ProductsID)
{
SqlCommand objCmd = new SqlCommand("ADM_DspProductsBYID", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
SqlDataReader objDr;
objCon.Open();
objDr = objCmd.ExecuteReader();
ListobjList = new List ();
if (objDr.HasRows)
{
objDr.Read();
Products objBol = new Products();
objBol.ProductsID = Convert.ToInt32(objDr["ProductsID"]);
objBol.Products_Name = objDr["Products_Name"].ToString();
objBol.Model = objDr["Model"].ToString();
objBol.Products_Description = objDr["Products_Description"].ToString();
objBol.Meta_keywords = objDr["Meta_keywords"].ToString();
objBol.Products_Type = Convert.ToInt32(objDr["Products_Type"]);
objBol.Show_quantity = Convert.ToBoolean(objDr["Show_quantity"]);
objBol.Price = Convert.ToDecimal(objDr["Price"]);
objBol.Active = Convert.ToBoolean(objDr["Active"]);
objBol.Meta_Description = objDr["Meta_Description"].ToString();
objBol.Meta_Title = objDr["Meta_Title"].ToString();
objList.Add(objBol);
}
objDr.Close();
objCmd.Dispose();
objCon.Close();
return objList;
}
//Dipslay product Details [ADM_DspProductsDetail]
public DataSet Dal_DspProductsDetails(int productID)
{
SqlDataAdapter objadp = new SqlDataAdapter("ADM_DspProductsDetail", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@ProductsID", SqlDbType.Int).Value = productID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
//[ADM_ProductSearch]
//@searchItem varchar(50)
public DataSet Dal_ADM_ProductSearch(string searchItem)
{
SqlDataAdapter objadp = new SqlDataAdapter("ADM_ProductSearch", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@searchItem", SqlDbType.VarChar).Value = searchItem;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
// Display Products Size [ADM_DspProductsSize]
public DataSet Dal_DspProductsSize(int productID)
{
SqlDataAdapter objadp = new SqlDataAdapter("ADM_DspProductsSizeBYID", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@ProductsID", SqlDbType.Int).Value = productID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
public ListDal_FillProductsolour(int productID)
{
SqlCommand objCmd = new SqlCommand("ADM_FillProductsColour", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = productID;
SqlDataReader objDr;
objCon.Open();
objDr = objCmd.ExecuteReader();
ListobjList = new List ();
if (objDr.HasRows)
{
while (objDr.Read())
{
Colour objBol = new Colour();
objBol.ColourID = Convert.ToInt32(objDr["ColourID"]);
objBol.Colour_name = objDr["Colour_name"].ToString();
objList.Add(objBol);
}
}
objDr.Close();
objCmd.Dispose();
objCon.Close();
return objList;
}
//Display products Category [ADM_DspProducts_Category]
public DataSet DAL_DiplayProductsCategories(int ProductsID)
{
SqlDataAdapter objadp = new SqlDataAdapter("ADM_DspProducts_Category", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
public ListDal_DspProductsImages(int productID)
{
SqlCommand objCmd = new SqlCommand("ADM_DspProducts_images", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = productID;
SqlDataReader objDr;
objCon.Open();
objDr = objCmd.ExecuteReader();
ListobjList = new List ();
if (objDr.HasRows)
{
while (objDr.Read())
{
Products objBol = new Products();
objBol.Products_imageID = Convert.ToInt32(objDr["Products_imageID"]);
objBol.ProductsID = Convert.ToInt32(objDr["ProductsID"]);
objBol.ColourID = Convert.ToInt32(objDr["ColourID"]);
objBol.Icon_image = objDr["Icon_image"].ToString();
objBol.Medium_image = objDr["Medium_image"].ToString();
objBol.Large_image =objDr["Large_image"].ToString ();
objBol.Colour_name = objDr["Colour_name"].ToString();
objBol.default_style = Convert.ToBoolean (objDr["default_style"]);
objList.Add(objBol);
}
}
objDr.Close();
objCmd.Dispose();
objCon.Close();
return objList;
}
//[ADM_DspProducts_imagesBYID]
public ListDal_DspProductsImagesBYID(int productID)
{
SqlCommand objCmd = new SqlCommand("ADM_DspProducts_imagesBYID", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_imageID", SqlDbType.Int).Value = productID;
SqlDataReader objDr;
objCon.Open();
objDr = objCmd.ExecuteReader();
ListobjList = new List ();
if (objDr.HasRows)
{
objDr.Read();
Products objBol = new Products();
objBol.Products_imageID = Convert.ToInt32(objDr["Products_imageID"]);
objBol.ProductsID = Convert.ToInt32(objDr["ProductsID"]);
objBol.ColourID = Convert.ToInt32(objDr["ColourID"]);
objBol.Icon_image = objDr["Icon_image"].ToString();
objBol.Medium_image = objDr["Medium_image"].ToString();
objBol.Large_image = objDr["Large_image"].ToString();
objBol.Colour_name = objDr["Colour_name"].ToString();
objBol.default_style = Convert.ToBoolean(objDr["default_style"]);
objList.Add(objBol);
}
objDr.Close();
objCmd.Dispose();
objCon.Close();
return objList;
}
//Delete Products Images [ADM_DelProductsImages]
public int DAL_DeleteProductsImages(int ProductImageID)
{
SqlCommand objCmd = new SqlCommand("ADM_DelProductsImages", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_imageID", SqlDbType.Int).Value = ProductImageID;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
//Delete Products To Categories [ADM_DelProductsToCategories]
public void DAL_DeleteProductsToCategories(int Products_categoryID)
{
SqlCommand objCmd = new SqlCommand("ADM_DelProductsToCategories", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_categoryID", SqlDbType.Int).Value = Products_categoryID;
objCon.Open();
objCmd.ExecuteNonQuery();
objCmd.Dispose();
objCon.Close();
}
//Delete Products Size [ADM_DelProductsSize]
public void DAL_DeleteProductsSize(int Products_sizeID)
{
SqlCommand objCmd = new SqlCommand("ADM_DelProductsSize", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@Products_sizeID", SqlDbType.Int).Value = Products_sizeID;
objCon.Open();
objCmd.ExecuteNonQuery();
objCmd.Dispose();
objCon.Close();
}
//Delte Products From all related tables [ADM_DelProducts]
public void DAL_DeleteProducts(int ProductsID)
{
SqlCommand objCmd = new SqlCommand("ADM_DelProducts", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
objCon.Open();
objCmd.ExecuteNonQuery();
objCmd.Dispose();
objCon.Close();
}
//////////////////////////////Colour///////////////////////////////
public int DAL_InsUpdColour(Colour objBol)
{
SqlCommand objCmd = new SqlCommand("ADM_InsUpdColour", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ColourID", SqlDbType.Int).Value = objBol.ColourID;
objCmd.Parameters.Add("@Colour_name", SqlDbType.NVarChar).Value = objBol.Colour_name;
objCon.Open();
int intRetval = Convert.ToInt32(objCmd.ExecuteScalar());
objCmd.Dispose();
objCon.Close();
return intRetval;
}
public ListDal_DspColour()
{
SqlCommand objCmd = new SqlCommand("ADM_DspColour", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
SqlDataReader objDr;
objCon.Open();
objDr = objCmd.ExecuteReader();
ListobjList = new List ();
if (objDr.HasRows)
{
while (objDr.Read())
{
Colour objBol = new Colour();
objBol.ColourID = Convert.ToInt32(objDr["ColourID"]);
objBol.Colour_name = objDr["Colour_name"].ToString();
objList.Add(objBol);
}
}
objDr.Close();
objCmd.Dispose();
objCon.Close();
return objList;
}
public void DAL_DeleteColour(int ColourID)
{
SqlCommand objCmd = new SqlCommand("ADM_DelColour", objCon);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.Add("@ColourID", SqlDbType.Int).Value = ColourID;
objCon.Open();
objCmd.ExecuteNonQuery();
objCmd.Dispose();
objCon.Close();
}
///////////////////////////////CLIENT SITE FUNCTIONS/////////////////////////////
//To Display Rotate Products [Get_Products]
public DataSet Dal_GetRotateProducts(int CategoryID)
{
SqlDataAdapter objadp = new SqlDataAdapter("Get_Products", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@CategoryID", SqlDbType.Int).Value = CategoryID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
// To Display Products Detail [Get_ProductsDetail]
public DataSet Dal_Get_ProductsDetail(int ProductsID)
{
SqlDataAdapter objadp = new SqlDataAdapter("Get_ProductsDetail", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
//Display Products Size [Get_ProductsSize]
public DataSet Dal_Get_ProductsSize(int ColourID,int ProductsID)
{
SqlDataAdapter objadp = new SqlDataAdapter("Get_ProductsSize", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@ColourID", SqlDbType.Int).Value = ColourID;
objadp.SelectCommand.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
//Displya Products Colour [Get_ProductsColour]
public DataSet Dal_Get_ProductsColour(int ProductsID)
{
SqlDataAdapter objadp = new SqlDataAdapter("Get_ProductsColour", objCon);
objadp.SelectCommand.CommandType = CommandType.StoredProcedure;
objadp.SelectCommand.Parameters.Add("@ProductsID", SqlDbType.Int).Value = ProductsID;
DataSet objds = new DataSet();
objadp.Fill(objds);
return objds;
}
}
}
24.7.10
22.7.10
How to implement Custom paging Using ASP.NET Data Grid
How to implement Custom paging Using ASP.NET Data Grid
You have Inbuilt paging facility for some of the data binding control like data grid. But it can be very inefficient. Control like repeater you don’t have inbuilt data binding facility. When you are using inbuilt paging facility it loads all the rows so very resource consuming and inefficient. But when you are using custom paging facility you return only requested rows.
Here we will examine how can we implement custom paging for data Grid using stored procedure. Here is the implementation of stored procedure. Here you have 3 parameter for stored procedure.
@page is basically page number in data grid
@pageSize is Number of records you are going to show one page
@TotalNofRecords is output parameter. It return total Number of records in the Query
Here when you go through the stored procedure you have create a tempory table and you retrieve only required data rows from that tempory table. Using @StartRecordNo and @EndRecordNo
Create PROCEDURE [dbo].[GetEmployee]
(
@Page int,
@PageSize int,
@TotalNofRecords int output
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @StartRecordNo int, @EndRecordNo int
IF (@Page=0)
BEGIN
SET @StartRecordNo = 1
SET @EndRecordNo = @PageSize
END
ELSE
BEGIN
SET @StartRecordNo = @PageSize * @Page + 1
SET @EndRecordNo = (@PageSize * (@Page+1) )
END
CREATE TABLE [#TmpEmployee]
(
[RowNo] int identity(1,1),
[EmployName] int not null,
[Address] varchar(255)
)
INSERT INTO [#TmpEmployee]([EmployName], [Address])
SELECT
FirstName, Address1
FROM Employee
ORDER BY FirstName
SELECT @TotalNofRecords = COUNT( FirstName) FROM [#TmpEmployee]
SET NOCOUNT OFF
SELECT [RowNo], [FirstName], [Address]
FROM [#TmpEmployee]
WHERE [RowNo]>= @StartRecordNo
AND [RowNo]<= @EndRecordNo
RETURN 0
END
When you bind the grid you can have method call BindGrid method
private void BindGrid(int pageNo)
{
try
{
int locationId ;
int recordsPerPage = 10 ;
int totalRecords = 0;
DataTable empList = EmpService.GetEmployee( pageNo, recordsPerPage ,ref totalRecords);
if (empList.Rows.Count > 0)
{
uxEmployeGrid.DataSource = jobsList;
uxEmployeGrid.VirtualItemCount = totalRecords;
uxEmployeGrid.DataBind();
}
}
catch(Exception ex)
{
throw ex;
}
}
When call the first time call the BindGrid Method with pageNo = 0
BindGrid(0);
When click the paging call the BindGrid method
protected void uxEmployeGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
uxEmployeGrid.CurrentPageIndex = e.NewPageIndex;
BindGrid(uxEmployeGrid.CurrentPageIndex);
}
You have Inbuilt paging facility for some of the data binding control like data grid. But it can be very inefficient. Control like repeater you don’t have inbuilt data binding facility. When you are using inbuilt paging facility it loads all the rows so very resource consuming and inefficient. But when you are using custom paging facility you return only requested rows.
Here we will examine how can we implement custom paging for data Grid using stored procedure. Here is the implementation of stored procedure. Here you have 3 parameter for stored procedure.
@page is basically page number in data grid
@pageSize is Number of records you are going to show one page
@TotalNofRecords is output parameter. It return total Number of records in the Query
Here when you go through the stored procedure you have create a tempory table and you retrieve only required data rows from that tempory table. Using @StartRecordNo and @EndRecordNo
Create PROCEDURE [dbo].[GetEmployee]
(
@Page int,
@PageSize int,
@TotalNofRecords int output
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @StartRecordNo int, @EndRecordNo int
IF (@Page=0)
BEGIN
SET @StartRecordNo = 1
SET @EndRecordNo = @PageSize
END
ELSE
BEGIN
SET @StartRecordNo = @PageSize * @Page + 1
SET @EndRecordNo = (@PageSize * (@Page+1) )
END
CREATE TABLE [#TmpEmployee]
(
[RowNo] int identity(1,1),
[EmployName] int not null,
[Address] varchar(255)
)
INSERT INTO [#TmpEmployee]([EmployName], [Address])
SELECT
FirstName, Address1
FROM Employee
ORDER BY FirstName
SELECT @TotalNofRecords = COUNT( FirstName) FROM [#TmpEmployee]
SET NOCOUNT OFF
SELECT [RowNo], [FirstName], [Address]
FROM [#TmpEmployee]
WHERE [RowNo]>= @StartRecordNo
AND [RowNo]<= @EndRecordNo
RETURN 0
END
When you bind the grid you can have method call BindGrid method
private void BindGrid(int pageNo)
{
try
{
int locationId ;
int recordsPerPage = 10 ;
int totalRecords = 0;
DataTable empList = EmpService.GetEmployee( pageNo, recordsPerPage ,ref totalRecords);
if (empList.Rows.Count > 0)
{
uxEmployeGrid.DataSource = jobsList;
uxEmployeGrid.VirtualItemCount = totalRecords;
uxEmployeGrid.DataBind();
}
}
catch(Exception ex)
{
throw ex;
}
}
When call the first time call the BindGrid Method with pageNo = 0
BindGrid(0);
When click the paging call the BindGrid method
protected void uxEmployeGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
uxEmployeGrid.CurrentPageIndex = e.NewPageIndex;
BindGrid(uxEmployeGrid.CurrentPageIndex);
}
asynchronous
http://www.webopedia.com/TERM/A/asynchronous.html
http://forums.asp.net/p/753551/805432.aspx
http://forums.asp.net/p/753551/805432.aspx
21.7.10
11.7.10
9.7.10
2.7.10
Free Sql server Training
http://www.sqlservervideos.com/
http://weblogs.asp.net/scottgu/archive/2007/03/01/free-sql-server-training-videos-and-other-good-data-tutorial-pointers.aspx
http://www.learnitfirst.com/Course/152/SQL-Server-2005-DBA/TheBigList.aspx
http://weblogs.asp.net/scottgu/archive/2007/03/01/free-sql-server-training-videos-and-other-good-data-tutorial-pointers.aspx
http://www.learnitfirst.com/Course/152/SQL-Server-2005-DBA/TheBigList.aspx
Forms Authentication and Roles in ASP.NET with C#: Advance
http://www.dotnetfunda.com/articles/article114.aspx
http://www.dotnetfunda.com/articles/article141.aspx
http://www.codeproject.com/KB/aspnet/custom_authentication.aspx
http://www.dotnetfunda.com/articles/article141.aspx
http://www.codeproject.com/KB/aspnet/custom_authentication.aspx
1.7.10
Authentication and Authorization in ASP.NET
http://aspalliance.com/907_Authentication_and_Authorization_in_ASPNET.1
29.6.10
26.6.10
Interfaces in C#
http://www.codeguru.com/csharp/csharp/cs_syntax/interfaces/article.php/c7563/Interfaces-in-C.htm
25.6.10
Explaining C# Abstraction, Inheritence and Polymorphism
http://www.csharphelp.com/2007/08/explaining-c-abstraction-inheritence-and-polymorphism/
OOPS Concepts and .NET Part 2:
http://www.c-sharpcorner.com/uploadfile/eecabral/oopsand.net211102005075520am/oopsand.net2.aspx
http://www.c-sharpcorner.com/UploadFile/ecabral/OOPSandDotNET106252005024236AM/OOPSandDotNET1.aspx
http://www.c-sharpcorner.com/UploadFile/ecabral/OOPSandDotNET106252005024236AM/OOPSandDotNET1.aspx
20.6.10
Forums of Different Languages
http://forums.asp.net/p/1337412/2699239.aspx#2699239 and my blog at http://geekswithblogs.net/TATWORTH/Default.aspx
18.6.10
select only date/time part of a datetime
How can I select only date/time part of a datetime value?
--------------------------------------------------------------------------------
Answer:
--to select date part only
SELECT CONVERT(char(10),GetDate(),101)
--to select time part only
SELECT right(GetDate(),7)
--------------------------------------------------------------------------------
Answer:
--to select date part only
SELECT CONVERT(char(10),GetDate(),101)
--to select time part only
SELECT right(GetDate(),7)
17.6.10
Business Logic Layer importance
http://www.dotnetfunda.com/forums/thread482-business-logic-layer-importance.aspx
Understanding three tier architecture
http://www.c-sharpcorner.com/UploadFile/rishiraveendran/806/Default.aspx
16.6.10
15.6.10
Advantages and disadvantages of state management
http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx
14.6.10
12.6.10
What's the advantage of disadvantage of using static method for data access
http://forums.asp.net/t/1343290.aspx?PageIndex=2
http://odetocode.com/articles/313.aspx
http://odetocode.com/Articles/314.aspx
http://odetocode.com/articles/313.aspx
http://odetocode.com/Articles/314.aspx
10.6.10
Generic Types in C# 2.0 with Sample
http://www.c-sharpcorner.com/UploadFile/abhishekbhatore/GenericTypeWithSample07292005092634AM/GenericTypeWithSample.aspx
Cryptography in .NET
http://www.c-sharpcorner.com/UploadFile/Suprotim/CryptographyInDotNET11282005053700AM/CryptographyInDotNET.aspx
Explain about Protected and protected internal, ?internal? access-specifier?
http://www.allinterview.com/showanswers/4903.html
6.6.10
4.6.10
How Ajax Works??
http://www.interaktonline.com/Support/Articles/Details/AJAX:+Asynchronously+Moving+Forward-How+does+AJAX+work%3F.html?id_art=36&id_asc=308
30.5.10
Group options in DropDownList
http://weblogs.asp.net/alaaalnajjar/archive/2009/11/16/group-options-in-dropdownlist.aspx
29.5.10
19.5.10
Determine Browser type from Server side using ASP.NET & C#?
http://stackoverflow.com/questions/2311077/how-to-determine-browser-type-from-server-side-using-asp-net-c
9.5.10
Grid View Paging and Sorting
Grid View Paging and Sorting
http://www.dotnetspider.com/resources/1249-Grid-View-Paging-Sorting.aspx
Implement sorting in GridView without using DataSources
http://aspdotnetcode.source-of-humor.com/Articles/GridView/ImplementDataSortingInGridViewUsingDataTable.aspx
http://www.dotnetspider.com/resources/1249-Grid-View-Paging-Sorting.aspx
Implement sorting in GridView without using DataSources
http://aspdotnetcode.source-of-humor.com/Articles/GridView/ImplementDataSortingInGridViewUsingDataTable.aspx
Refresh Web Pages After Download Completed
Refresh Web Pages After Download Completed
http://www.eggheadcafe.com/tutorials/aspnet/3889fc21-1562-4d1b-89e4-cea5576690b2/refresh-web-pages-after-d.aspx
JavaScript Refresh Page
http://www.quackit.com/javascript/javascript_refresh_page.cfm
http://www.eggheadcafe.com/tutorials/aspnet/3889fc21-1562-4d1b-89e4-cea5576690b2/refresh-web-pages-after-d.aspx
JavaScript Refresh Page
http://www.quackit.com/javascript/javascript_refresh_page.cfm
29.4.10
Google forum for Custom Search, Checkout Merchant, Google Chat, Google Sites
http://www.google.com/support/forum/
28.4.10
Google Site Search (Free or paid service )
http://www.google.com/sitesearch/
http://www.google.com/cse/
http://www.google.com/cse/
18.4.10
JSON(Javascript Object Notation )
http://www.asp.net/Learn/mvc-videos/video-8676.aspx
http://www.wrox.com/WileyCDA/Section/Introduction-to-JSON.id-302782.html
http://www.wrox.com/WileyCDA/Section/Introduction-to-JSON.id-302782.html
Difference Between WPF and Silverlight
http://www.differencebetween.net/technology/difference-between-wpf-and-silverlight/
WCF (Windows Communication Foundation)
http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=206
WPF(Windows Presentation Foundation)
VIDEO
http://windowsclient.net/learn/video.aspx?v=315275
----------------------------------------------------------------
http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=211
http://windowsclient.net/learn/video.aspx?v=315275
----------------------------------------------------------------
http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=211
Using LINQ(Language Integrated Query) with ASP.NET
dbml(DataBase Markup Language)
http://weblogs.asp.net/scottgu/archive/2007/01/28/video-using-linq-with-asp-net-in-vs-orcas-part-1.aspx
http://weblogs.asp.net/scottgu/archive/2007/01/28/video-using-linq-with-asp-net-in-vs-orcas-part-1.aspx
14.4.10
Required Field Fire for every row for Gridview
RequiredFieldValidator for column
RequiredFieldValidator used to mention the mandatory field or compulsory field. It won’t allow you to leave the field empty. Below is the code to create RequiredFieldValidator dynamically.
RequiredFieldValidator reqfldVal = new RequiredFieldValidator();
reqfldVal.ID = "RequiredValidator10";
reqfldVal.ControlToValidate = "t5";
reqfldVal.ErrorMessage = "City Required";
reqfldVal.SetFocusOnError = true;
e.Row.Cells[4].Controls.Add(reqfldVal);
========================================================
Don't use validation group in aspx page, it is use in .cs page.
Guid gui=guid.New();
reqfldVal.Validationgroup =convert.tostring(gui);
===========================================================
http://www.itprojectsforyou.com/validate_gridview.php
RequiredFieldValidator used to mention the mandatory field or compulsory field. It won’t allow you to leave the field empty. Below is the code to create RequiredFieldValidator dynamically.
RequiredFieldValidator reqfldVal = new RequiredFieldValidator();
reqfldVal.ID = "RequiredValidator10";
reqfldVal.ControlToValidate = "t5";
reqfldVal.ErrorMessage = "City Required";
reqfldVal.SetFocusOnError = true;
e.Row.Cells[4].Controls.Add(reqfldVal);
========================================================
Don't use validation group in aspx page, it is use in .cs page.
Guid gui=guid.New();
reqfldVal.Validationgroup =convert.tostring(gui);
===========================================================
http://www.itprojectsforyou.com/validate_gridview.php
3.4.10
Search a particular text string in all SPs
http://www.sqlservercentral.com/Search/?q=search+text+in+sp&t=a&t=b&t=f&t=s
********************************************************
SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%Prod%'
SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE Definition LIKE '%Prod%'
AND OBJECTPROPERTY(object_id, 'IsProcedure') = 1
--nvarchar(4000)
SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%Prod%'
AND ROUTINE_TYPE = 'PROCEDURE'
********************************************************
********************************************************
SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%Prod%'
SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE Definition LIKE '%Prod%'
AND OBJECTPROPERTY(object_id, 'IsProcedure') = 1
--nvarchar(4000)
SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%Prod%'
AND ROUTINE_TYPE = 'PROCEDURE'
********************************************************
Searching Column Name in All Tables
http://www.sqlservercentral.com/scripts/68998/
*********************************************
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%ColumnName%'
*********************************************
*********************************************
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%ColumnName%'
*********************************************
Find Text in all columns of all tables in a Database
http://www.sqlservercentral.com/scripts/Miscellaneous/65769/
**********************************************************************
DECLARE @TEXT VARCHAR(500)
SET @TEXT = 'DBAdmin'
DECLARE @TABLES TABLE([id] INT IDENTITY(1,1), TableName VARCHAR(500), ColumnName VARCHAR(500))
INSERT INTO @TABLES(TableName, ColumnName)
SELECT O.[NAME], C.[NAME]--SELECT *
FROM SYSOBJECTS O
JOIN SYSCOLUMNS C
ON C.ID = O.ID
WHERE O.XTYPE = 'U'
AND C.XTYPE NOT IN
(
127 --bigint
, 173 --binary
, 104 --bit
, 61 --datetime
, 106 --decimal
, 62 --float
, 34 --image
, 56 --int
, 60 --money
, 108 --numeric
, 59 --real
, 58 --smalldatetime
, 52 --smallint
, 122 --smallmoney
, 189 --timestamp
, 48 --tinyint
, 36 --uniqueidentifier
, 165 --varbinary
)
ORDER BY O.[NAME], C.[NAME]
IF EXISTS (SELECT NAME FROM TEMPDB.DBO.SYSOBJECTS WHERE NAME LIKE '#TMPREPORT%')
BEGIN
DROP TABLE #TMPREPORT
END
CREATE TABLE #TMPREPORT(COUNTER INT, TABLENAME VARCHAR(500), COLUMNNAME VARCHAR(500))
DECLARE @CNTR INT, @POS INT, @TableName VARCHAR(500), @ColumnName VARCHAR(500), @SQL VARCHAR(8000)
SELECT @POS = 1, @CNTR = MAX([ID]), @TableName = '', @ColumnName = ''
FROM @TABLES
--SELECT @POS, @CNTR, * FROM @TABLES
WHILE @POS <= @CNTR
BEGIN
SELECT @TableName = TableName, @ColumnName = ColumnName
FROM @TABLES
WHERE [ID] = @POS
SELECT @SQL = 'SELECT COUNT(*), ''' + @TABLENAME + ''' [TABLE],''' + @COLUMNNAME + '''[COLUMN] FROM ' + @TableName + ' WHERE CAST(' + @ColumnName + ' AS VARCHAR) LIKE ''%' + @TEXT + '%'''
--PRINT @SQL
BEGIN TRY
INSERT INTO #TMPREPORT(COUNTER, TABLENAME, COLUMNNAME)
EXEC(@SQL)
END TRY
BEGIN CATCH
PRINT @@ERROR
PRINT @SQL
END CATCH
SELECT @POS = @POS + 1
END
SELECT * FROM #TMPREPORT WHERE COUNTER > 0
DROP TABLE #TMPREPORT
----------------------------------------------------------------------------------------
/*127 : bigint
173' --binary
104' --bit
175' --char
61' --datetime
106' --decimal
62' --float
34' --image
56' --int
60' --money
239' --nchar
99' --ntext
108' --numeric
231' --nvarchar
59' --real
58' --smalldatetime
52' --smallint
122' --smallmoney
98' --sql_variant
231' --sysname
35' --text
189' --timestamp
48' --tinyint
36' --uniqueidentifier
165' --varbinary
167' --varchar
*/
**********************************************************************
**********************************************************************
DECLARE @TEXT VARCHAR(500)
SET @TEXT = 'DBAdmin'
DECLARE @TABLES TABLE([id] INT IDENTITY(1,1), TableName VARCHAR(500), ColumnName VARCHAR(500))
INSERT INTO @TABLES(TableName, ColumnName)
SELECT O.[NAME], C.[NAME]--SELECT *
FROM SYSOBJECTS O
JOIN SYSCOLUMNS C
ON C.ID = O.ID
WHERE O.XTYPE = 'U'
AND C.XTYPE NOT IN
(
127 --bigint
, 173 --binary
, 104 --bit
, 61 --datetime
, 106 --decimal
, 62 --float
, 34 --image
, 56 --int
, 60 --money
, 108 --numeric
, 59 --real
, 58 --smalldatetime
, 52 --smallint
, 122 --smallmoney
, 189 --timestamp
, 48 --tinyint
, 36 --uniqueidentifier
, 165 --varbinary
)
ORDER BY O.[NAME], C.[NAME]
IF EXISTS (SELECT NAME FROM TEMPDB.DBO.SYSOBJECTS WHERE NAME LIKE '#TMPREPORT%')
BEGIN
DROP TABLE #TMPREPORT
END
CREATE TABLE #TMPREPORT(COUNTER INT, TABLENAME VARCHAR(500), COLUMNNAME VARCHAR(500))
DECLARE @CNTR INT, @POS INT, @TableName VARCHAR(500), @ColumnName VARCHAR(500), @SQL VARCHAR(8000)
SELECT @POS = 1, @CNTR = MAX([ID]), @TableName = '', @ColumnName = ''
FROM @TABLES
--SELECT @POS, @CNTR, * FROM @TABLES
WHILE @POS <= @CNTR
BEGIN
SELECT @TableName = TableName, @ColumnName = ColumnName
FROM @TABLES
WHERE [ID] = @POS
SELECT @SQL = 'SELECT COUNT(*), ''' + @TABLENAME + ''' [TABLE],''' + @COLUMNNAME + '''[COLUMN] FROM ' + @TableName + ' WHERE CAST(' + @ColumnName + ' AS VARCHAR) LIKE ''%' + @TEXT + '%'''
--PRINT @SQL
BEGIN TRY
INSERT INTO #TMPREPORT(COUNTER, TABLENAME, COLUMNNAME)
EXEC(@SQL)
END TRY
BEGIN CATCH
PRINT @@ERROR
PRINT @SQL
END CATCH
SELECT @POS = @POS + 1
END
SELECT * FROM #TMPREPORT WHERE COUNTER > 0
DROP TABLE #TMPREPORT
----------------------------------------------------------------------------------------
/*127 : bigint
173' --binary
104' --bit
175' --char
61' --datetime
106' --decimal
62' --float
34' --image
56' --int
60' --money
239' --nchar
99' --ntext
108' --numeric
231' --nvarchar
59' --real
58' --smalldatetime
52' --smallint
122' --smallmoney
98' --sql_variant
231' --sysname
35' --text
189' --timestamp
48' --tinyint
36' --uniqueidentifier
165' --varbinary
167' --varchar
*/
**********************************************************************
With Sql Generate Parameters for store procedure
******************************************************************************
select '@' + LOWER(substring(column_name,1,1)) + substring(column_name,2,Len(column_name)) + ' ' + UPPER(Data_Type) + CASE WHEN character_maximum_length is null THEN ',' ELSE ' (' + CAST(character_maximum_length as VARCHAR(200))+ '),' END from Information_Schema.columns
where Table_Name ='studentbatchResult'
*******************************************************************************
select 'db.AddInParameter(command, "@' +
LOWER(substring(column_name,1,1)) + substring(column_name,2,Len(column_name)) + '", DbType.' +
CASE WHEN Data_Type = 'VARCHAR' THEN 'String' WHEN Data_Type = 'int' THEN 'Int32'
WHEN Data_Type = 'DateTime' Then 'DateTime' WHEN Data_Type = 'bit' THEN 'Boolean' WHEN Data_Type = 'text' THEN 'String' END + ', objUser.' + column_Name + ');' from Information_Schema.columns where Table_Name ='tbl_UserDetails'
********************************************************************************
select '@' + LOWER(substring(column_name,1,1)) + substring(column_name,2,Len(column_name)) + ' ' + UPPER(Data_Type) + CASE WHEN character_maximum_length is null THEN ',' ELSE ' (' + CAST(character_maximum_length as VARCHAR(200))+ '),' END from Information_Schema.columns
where Table_Name ='studentbatchResult'
*******************************************************************************
select 'db.AddInParameter(command, "@' +
LOWER(substring(column_name,1,1)) + substring(column_name,2,Len(column_name)) + '", DbType.' +
CASE WHEN Data_Type = 'VARCHAR' THEN 'String' WHEN Data_Type = 'int' THEN 'Int32'
WHEN Data_Type = 'DateTime' Then 'DateTime' WHEN Data_Type = 'bit' THEN 'Boolean' WHEN Data_Type = 'text' THEN 'String' END + ', objUser.' + column_Name + ');' from Information_Schema.columns where Table_Name ='tbl_UserDetails'
********************************************************************************
with Sql Generate DAL Parameters
***********************************************************************
select 'if (string.IsNullOrEmpty(myBatchFileResult.' + substring(column_name,1,Len(column_name))+')){
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name)) +'", DBNull.Value);
}
else
{
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name))+'", myBatchFileResult.'+ substring(column_name,1,Len(column_name)) +');
}'
from Information_Schema.columns where Table_Name ='BatchUploadResult'
***************************************************
select 'if (string.IsNullOrEmpty(myBatchFileResult.' + substring(column_name,1,Len(column_name))+')){
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name)) +'", DBNull.Value);
}
else
{
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name))+'", myBatchFileResult.'+ substring(column_name,1,Len(column_name)) +');
}'
from Information_Schema.columns where Table_Name ='StudentBatchResult'
*************************************************************************
select 'if (string.IsNullOrEmpty(myBatchFileResult.' + substring(column_name,1,Len(column_name))+')){
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name)) +'", DBNull.Value);
}
else
{
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name))+'", myBatchFileResult.'+ substring(column_name,1,Len(column_name)) +');
}'
from Information_Schema.columns where Table_Name ='BatchUploadResult'
***************************************************
select 'if (string.IsNullOrEmpty(myBatchFileResult.' + substring(column_name,1,Len(column_name))+')){
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name)) +'", DBNull.Value);
}
else
{
myCommand.Parameters.AddWithValue("@' + substring(column_name,1,Len(column_name))+'", myBatchFileResult.'+ substring(column_name,1,Len(column_name)) +');
}'
from Information_Schema.columns where Table_Name ='StudentBatchResult'
*************************************************************************
With Sql Generate C# class code for table
http://www.sqlservercentral.com/scripts/Development/61477/
NOTE:first signup, if you are not registered with this website
*************************************************
CREATE PROCEDURE usp_TableToClass
/*
Created by Cade Bryant.
Generates C# class code for a table
and fields/properties for each column.
Run as "Results to Text" or "Results to File" (not Grid)
Example: EXEC usp_TableToClass 'MyTable'
*/
@table_name SYSNAME
AS
SET NOCOUNT ON
DECLARE @temp TABLE
(
sort INT,
code TEXT
)
INSERT INTO @temp
SELECT 1, 'public class ' + @table_name + CHAR(13) + CHAR(10) + '{'
INSERT INTO @temp
SELECT 2, CHAR(13) + CHAR(10) + '#region Constructors' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 3, CHAR(9) + 'public ' + @table_name + '()'
+ CHAR(13) + CHAR(10) + CHAR(9) + '{'
+ CHAR(13) + CHAR(10) + CHAR(9) + '}'
INSERT INTO @temp
SELECT 4, '#endregion' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 5, '#region Private Fields' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 6, CHAR(9) + 'private ' +
CASE
WHEN DATA_TYPE LIKE '%CHAR%' THEN 'string '
WHEN DATA_TYPE LIKE '%INT%' THEN 'int '
WHEN DATA_TYPE LIKE '%DATETIME%' THEN 'DateTime '
WHEN DATA_TYPE LIKE '%BINARY%' THEN 'byte[] '
WHEN DATA_TYPE = 'BIT' THEN 'bool '
WHEN DATA_TYPE LIKE '%TEXT%' THEN 'string '
ELSE 'object '
END + '_' + COLUMN_NAME + ';' + CHAR(9)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = @table_name
ORDER BY ORDINAL_POSITION
INSERT INTO @temp
SELECT 7, '#endregion' +
CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 8, '#region Public Properties' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 9, CHAR(9) + 'public ' +
CASE
WHEN DATA_TYPE LIKE '%CHAR%' THEN 'string '
WHEN DATA_TYPE LIKE '%INT%' THEN 'int '
WHEN DATA_TYPE LIKE '%DATETIME%' THEN 'DateTime '
WHEN DATA_TYPE LIKE '%BINARY%' THEN 'byte[] '
WHEN DATA_TYPE = 'BIT' THEN 'bool '
WHEN DATA_TYPE LIKE '%TEXT%' THEN 'string '
ELSE 'object '
END + COLUMN_NAME +
CHAR(13) + CHAR(10) + CHAR(9) + '{' +
CHAR(13) + CHAR(10) + CHAR(9) + CHAR(9) +
'get { return _' + COLUMN_NAME + '; }' +
CHAR(13) + CHAR(10) + CHAR(9) + CHAR(9) +
'set { _' + COLUMN_NAME + ' = value; }' +
CHAR(13) + CHAR(10) + CHAR(9) + '}'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = @table_name
ORDER BY ORDINAL_POSITION
INSERT INTO @temp
SELECT 10, '#endregion' +
CHAR(13) + CHAR(10) + '}'
SELECT code FROM @temp
ORDER BY sort
*************************************************
NOTE:first signup, if you are not registered with this website
*************************************************
CREATE PROCEDURE usp_TableToClass
/*
Created by Cade Bryant.
Generates C# class code for a table
and fields/properties for each column.
Run as "Results to Text" or "Results to File" (not Grid)
Example: EXEC usp_TableToClass 'MyTable'
*/
@table_name SYSNAME
AS
SET NOCOUNT ON
DECLARE @temp TABLE
(
sort INT,
code TEXT
)
INSERT INTO @temp
SELECT 1, 'public class ' + @table_name + CHAR(13) + CHAR(10) + '{'
INSERT INTO @temp
SELECT 2, CHAR(13) + CHAR(10) + '#region Constructors' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 3, CHAR(9) + 'public ' + @table_name + '()'
+ CHAR(13) + CHAR(10) + CHAR(9) + '{'
+ CHAR(13) + CHAR(10) + CHAR(9) + '}'
INSERT INTO @temp
SELECT 4, '#endregion' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 5, '#region Private Fields' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 6, CHAR(9) + 'private ' +
CASE
WHEN DATA_TYPE LIKE '%CHAR%' THEN 'string '
WHEN DATA_TYPE LIKE '%INT%' THEN 'int '
WHEN DATA_TYPE LIKE '%DATETIME%' THEN 'DateTime '
WHEN DATA_TYPE LIKE '%BINARY%' THEN 'byte[] '
WHEN DATA_TYPE = 'BIT' THEN 'bool '
WHEN DATA_TYPE LIKE '%TEXT%' THEN 'string '
ELSE 'object '
END + '_' + COLUMN_NAME + ';' + CHAR(9)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = @table_name
ORDER BY ORDINAL_POSITION
INSERT INTO @temp
SELECT 7, '#endregion' +
CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 8, '#region Public Properties' + CHAR(13) + CHAR(10)
INSERT INTO @temp
SELECT 9, CHAR(9) + 'public ' +
CASE
WHEN DATA_TYPE LIKE '%CHAR%' THEN 'string '
WHEN DATA_TYPE LIKE '%INT%' THEN 'int '
WHEN DATA_TYPE LIKE '%DATETIME%' THEN 'DateTime '
WHEN DATA_TYPE LIKE '%BINARY%' THEN 'byte[] '
WHEN DATA_TYPE = 'BIT' THEN 'bool '
WHEN DATA_TYPE LIKE '%TEXT%' THEN 'string '
ELSE 'object '
END + COLUMN_NAME +
CHAR(13) + CHAR(10) + CHAR(9) + '{' +
CHAR(13) + CHAR(10) + CHAR(9) + CHAR(9) +
'get { return _' + COLUMN_NAME + '; }' +
CHAR(13) + CHAR(10) + CHAR(9) + CHAR(9) +
'set { _' + COLUMN_NAME + ' = value; }' +
CHAR(13) + CHAR(10) + CHAR(9) + '}'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = @table_name
ORDER BY ORDINAL_POSITION
INSERT INTO @temp
SELECT 10, '#endregion' +
CHAR(13) + CHAR(10) + '}'
SELECT code FROM @temp
ORDER BY sort
*************************************************
Error Handling: Catching Errors With ASP.Net and C#
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=68
Validation of viewstate MAC failed error
http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
Fisharoo settings Errors
http://forum.socialnetworkingin.net/yaf_postst14_Chapter-13-Compile-Errors.aspx
Downloading a File with a Save As Dialog in ASP.NET
Downloading a File with a Save As Dialog in ASP.NET
http://www.west-wind.com/weblog/posts/76293.aspx
http://www.west-wind.com/weblog/posts/76293.aspx
Contact us form with "Mail attachment"
Contact us form with "Mail attachment":
http://www.aspsnippets.com/Articles/Contact-Us-Form-with-Rich-TextBox-in-ASP.Net.aspx
http://www.aspsnippets.com/Articles/Contact-Us-Form-with-Rich-TextBox-in-ASP.Net.aspx
File Uploading System with Progress Bar ajax
http://aspalliance.com/1442_Building_AJAX_Enabled_File_Uploading_System_with_Progress_Bar_Using_ASPNET_20.all
Reading XML(EXtensible Markup Language.) Files with ASP.NET
http://www.dotnetfunda.com/forums/thread686-how-to-read-xml-file-with-aspnet-i-want-to-change-the-title-for-the.aspx
http://www.stardeveloper.com/articles/display.html?article=2009030701&page=1
http://www.stardeveloper.com/articles/display.html?article=2009030701&page=1
31.3.10
Nokia latest Series
http://dailymobile.se/2009/02/16/nokia-announce-new-e-series-phone-nokia-e75-and-e55/
Processors
Types
There are two primary manufacturers of computer microprocessors. Intel and Advanced Micro Devices (AMD) lead the market in terms of speed and quality. Intel's desktop CPUs include Celeron, Pentium, and Core. AMD's desktop processors include Sempron, Athlon, and Phenom. Intel makes Celeron M, Pentium M, and Core mobile processors for notebooks. AMD makes mobile versions of its Sempron and Athlon, as well as the Turion mobile processor which comes in Ultra and Dual-Core versions. Both companies make both single-core and multi-core processors.
Each processor has a clock speed which is measured in gigahertz (GHz).
A microprocessor is a silicon chip containing millions of microscopic transistors.
Latest processors:
http://www.intel.com/products/processor/index.htm
http://www.intel.com/products/processor/corei7ee/specifications.htm
There are two primary manufacturers of computer microprocessors. Intel and Advanced Micro Devices (AMD) lead the market in terms of speed and quality. Intel's desktop CPUs include Celeron, Pentium, and Core. AMD's desktop processors include Sempron, Athlon, and Phenom. Intel makes Celeron M, Pentium M, and Core mobile processors for notebooks. AMD makes mobile versions of its Sempron and Athlon, as well as the Turion mobile processor which comes in Ultra and Dual-Core versions. Both companies make both single-core and multi-core processors.
Each processor has a clock speed which is measured in gigahertz (GHz).
A microprocessor is a silicon chip containing millions of microscopic transistors.
Latest processors:
http://www.intel.com/products/processor/index.htm
http://www.intel.com/products/processor/corei7ee/specifications.htm
30.3.10
String split C#
1.)string split C#
string str = null;
string[] strArr = null;
int count = 0;
str = "CSharp split test";
char[] splitchar = { ' ' };
strArr = str.Split(splitchar);
for (count = 0; count < = strArr.Length - 1; count++)
{
MessageBox.Show(strArr[count]);
}
2.)RELACE STRING
string str = "This test";
// Replace string
str = str.Replace("is", "was");
3.)
string str = null;
string[] strArr = null;
int count = 0;
str = "CSharp split test";
char[] splitchar = { ' ' };
strArr = str.Split(splitchar);
for (count = 0; count < = strArr.Length - 1; count++)
{
MessageBox.Show(strArr[count]);
}
2.)RELACE STRING
string str = "This test";
// Replace string
str = str.Replace("is", "was");
3.)
MAX and MIN of Datetime
SELECT Id, Min(Time) as MinTime, Max(Time) as MaxTime FROM Frames GROUP
by Id
by Id
Saving xml data into database sql 2005
http://www.developer.com/net/net/article.php/3406251/Work-with-XML-Data-Type-in-SQL-Server-2005-from-ADONET-20.htm
25.3.10
20.3.10
Migrate MySQL to Microsoft SQL Server
http://www.codeproject.com/KB/database/migrate-mysql-to-mssql.aspx
19.3.10
16.3.10
Encrypt and decrypt query string easy for whole website
http://forums.asp.net/p/1118844/1741448.aspx
14.3.10
Instant SQl formater
Instant SQl formater
http://www.dpriver.com/pp/sqlformat.htm
write sql fast
http://www.sqlservercentral.com/articles/Product+Reviews/3050/
sql performance
http://www.sql-server-performance.com/tips/t_sql_where_p1.aspx
http://www.dpriver.com/pp/sqlformat.htm
write sql fast
http://www.sqlservercentral.com/articles/Product+Reviews/3050/
sql performance
http://www.sql-server-performance.com/tips/t_sql_where_p1.aspx
Write mail c#
Sending Email using C# and ASP.Net 2.0
http://www.codedigest.com/Articles/ASPNET/95_Sending_Email_using_C__and_ASPNet_20.aspx
Write body HtML with string builder
http://www.dotnetspider.com/forum/162323-How-write-Html-tags-email-body.aspx
http://www.codedigest.com/Articles/ASPNET/95_Sending_Email_using_C__and_ASPNet_20.aspx
Write body HtML with string builder
http://www.dotnetspider.com/forum/162323-How-write-Html-tags-email-body.aspx
call 2 javascript functions on click of single html button
input type="button" value="Calculate" onClick="(func1(), func2() )" >
CMS(Content management system)
List of content management systems
http://en.wikipedia.org/wiki/List_of_content_management_systems
Beer House CMS
http://thebeerhouse.codeplex.com/releases/view/33900
http://en.wikipedia.org/wiki/List_of_content_management_systems
Beer House CMS
http://thebeerhouse.codeplex.com/releases/view/33900
Convert SQL Server 2008 to SQL Server 2005
1.)Convert SQL Server 2008 to SQL Server 2005
http://www.hyper-v-mart.com/HowTo/Convert_SQL_Server_2008_to_SQL_Server_2005.aspx
2.)With data:
1) Right click the database in sql 2008 which you want to do with
2) Choose Task and Generate script
3) Make sure select "script all objects in the database"
4) In the Script Option, choose the item Script for SQL server version to SQL2005
and Script data to be true! Those two are the key steps!
5) Here you go to check the generated script. You should find out insert statement for inserting the data
3.)Debugging Stored Procedures in Visual Studio 2005
http://www.sqlteam.com/article/debugging-stored-procedures-in-visual-studio-2005
4.)Call Stored procedure from within another stored procedure, return values
http://www.aspfree.com/c/a/ASP.NET-Code/Call-Stored-procedure-from-within-another-stored-procedure-return-values/
5.) Differences between varchar and nvarchar in SQL Server
http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1266201,00.html
6.) Calling functions in sql.
http://www.functionx.com/sqlserver/functions/create.htm
http://www.hyper-v-mart.com/HowTo/Convert_SQL_Server_2008_to_SQL_Server_2005.aspx
2.)With data:
1) Right click the database in sql 2008 which you want to do with
2) Choose Task and Generate script
3) Make sure select "script all objects in the database"
4) In the Script Option, choose the item Script for SQL server version to SQL2005
and Script data to be true! Those two are the key steps!
5) Here you go to check the generated script. You should find out insert statement for inserting the data
3.)Debugging Stored Procedures in Visual Studio 2005
http://www.sqlteam.com/article/debugging-stored-procedures-in-visual-studio-2005
4.)Call Stored procedure from within another stored procedure, return values
http://www.aspfree.com/c/a/ASP.NET-Code/Call-Stored-procedure-from-within-another-stored-procedure-return-values/
5.) Differences between varchar and nvarchar in SQL Server
http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1266201,00.html
6.) Calling functions in sql.
http://www.functionx.com/sqlserver/functions/create.htm
13.3.10
Shortcut keys
1.)Remote desktop connection::
click ’start’ -> ‘Run…’ -> type ‘mstsc‘ in and click OK-> then you have it –
2.)Asp.net::
http://nerdfortress.s3.amazonaws.com/visual-studio-2008-keyboard-shortcuts.html
click ’start’ -> ‘Run…’ -> type ‘mstsc‘ in and click OK-> then you have it –
2.)Asp.net::
http://nerdfortress.s3.amazonaws.com/visual-studio-2008-keyboard-shortcuts.html
12.3.10
11.3.10
Multiple file upload like gmail with jquery
http://www.aspsnippets.com/Articles/Multiple-File-Uploads-Gmail-Style-using-JQuery-and-ASP.Net.aspx
8.3.10
Installing Silverlight 3.0 without errors is easy
Video:http://www.silverlight.net/learn/videos/silverlight-videos/getting-started-with-silverlight-development/
------------------------------------------------------
http://www.dotnetcurry.com/ShowArticle.aspx?ID=293
------------------------------------------------------
http://www.dotnetcurry.com/ShowArticle.aspx?ID=293
3.3.10
Norton ghost for window XP service pack 2
1.)http://service1.symantec.com/SUPPORT/powerquest.nsf/643c9edb8e8f93b788256ee00056a108/b424ef724f0b431788256f2d0060e03d?OpenDocument&src=bar_sch_nam
http://www.youtube.com/watch?v=C47pKqb9uzQ
http://www.youtube.com/watch?v=9ASeO8vTh58&NR=1
http://www.youtube.com/watch?v=C47pKqb9uzQ
http://www.youtube.com/watch?v=9ASeO8vTh58&NR=1
25.2.10
Sql Functions
NOLOCK
http://www.sqlservercentral.com/Forums/Topic282321-149-1.aspx
http://www.sqlservercentral.com/articles/Performance+Tuning/2764/
http://www.1keydata.com/sql/sql-use.html
SQL WILD CARDS:
http://www.techonthenet.com/sql/like.php
http://www.w3schools.com/SQL/sql_wildcards.asp
The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to
COMMIT or ROLLBACK the transaction to make the change permanent or to undo it.
TRUNCATE removes all rows from a table. The operation cannot be rolled back. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
The DROP command removes a table from the database. All the tables' rows,
indexes and privileges will also be removed. The operation cannot be rolled back.
DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.
********************************************************
TURN IMPLICIT TRANSACTION ON IN SQL:
http://blog.techdreams.org/2007/11/implicit-transactions-onoff-sql-server.html
http://www.allinterview.com/showanswers/71598.html
http://www.sqlservercentral.com/Forums/Topic282321-149-1.aspx
http://www.sqlservercentral.com/articles/Performance+Tuning/2764/
http://www.1keydata.com/sql/sql-use.html
SQL WILD CARDS:
http://www.techonthenet.com/sql/like.php
http://www.w3schools.com/SQL/sql_wildcards.asp
The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to
COMMIT or ROLLBACK the transaction to make the change permanent or to undo it.
TRUNCATE removes all rows from a table. The operation cannot be rolled back. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
The DROP command removes a table from the database. All the tables' rows,
indexes and privileges will also be removed. The operation cannot be rolled back.
DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.
********************************************************
TURN IMPLICIT TRANSACTION ON IN SQL:
http://blog.techdreams.org/2007/11/implicit-transactions-onoff-sql-server.html
http://www.allinterview.com/showanswers/71598.html
23.2.10
Send Mail through php(Hypertext Preprocessor)
http://www.w3schools.com/php/php_mail.asp
BCC,CC--
http://www.java2s.com/Code/Php/Form/SendemailwithCCandBCC.htm
BCC,CC--
http://www.java2s.com/Code/Php/Form/SendemailwithCCandBCC.htm
21.2.10
Send mail when Error occur in website
http://www.plugins4asp.net/tipsdetails.aspx?ID=50
http://dotnetguts.blogspot.com/2007/10/error-handling-in-net-with-example.html
http://www.mastercsharp.com/article.aspx?ArticleID=61&&TopicID=2
http://dotnetguts.blogspot.com/2007/10/error-handling-in-net-with-example.html
http://www.mastercsharp.com/article.aspx?ArticleID=61&&TopicID=2
Session Expire in 20 minutes or 2 minute
http://forums.asp.net/t/1283350.aspx
http://forums.asp.net/p/1332460/2676515.aspx
http://stackoverflow.com/questions/648992/session-timeout-in-asp-net
1.)http://www.velocityreviews.com/forums/t95194-go-to-login-page-when-session-expires.html
2.)http://zeeshanumardotnet.blogspot.com/2009/01/why-dot-net-sessions-are-cleared-before.html
3.)http://zeeshanumardotnet.blogspot.com/2009/07/why-sessions-are-terminatedloss.html
http://forums.asp.net/p/1332460/2676515.aspx
http://stackoverflow.com/questions/648992/session-timeout-in-asp-net
1.)http://www.velocityreviews.com/forums/t95194-go-to-login-page-when-session-expires.html
2.)http://zeeshanumardotnet.blogspot.com/2009/01/why-dot-net-sessions-are-cleared-before.html
3.)http://zeeshanumardotnet.blogspot.com/2009/07/why-sessions-are-terminatedloss.html
Validation of Mac failed
http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
1.)http://www.andreas-kraus.net/blog/validation-of-viewstate-mac-failed/
2.)http://www.pagedowntech.com/faq/faq.asp?faqid=145
3.)http://www.eukhost.com/forums/f15/fix-validation-viewstate-mac-failed-6085/
1.)http://www.andreas-kraus.net/blog/validation-of-viewstate-mac-failed/
2.)http://www.pagedowntech.com/faq/faq.asp?faqid=145
3.)http://www.eukhost.com/forums/f15/fix-validation-viewstate-mac-failed-6085/
20.2.10
Set a table’s visibility to false when it has no rows (in reporting services)
http://stackoverflow.com/questions/514043/set-a-tables-visibility-to-false-when-it-has-no-rows-in-reporting-services
18.2.10
Database Mirroring in SQL Server 2008
1.)Database Mirroring in SQL Server 2008
http://www.databasejournal.com/features/mssql/article.php/3828341/Database-Mirroring-in-SQL-Server-2008.htm
****************************************************************
2.)Replication in SQL Server 2008
http://www.databasejournal.com/features/mssql/article.php/3820361/Peer-to-Peer-Replication-in-SQL-Server-2008--Add-a-node-and-resolve-conflict.htm
*****************************************************************
3.)get day from datetime
DATENAME ( datepart ,date )
http://msdn.microsoft.com/en-us/library/ms174395(SQL.90).aspx
******************************************************************
4.) Delete temp data from pc shortcut
run type:%temp%
http://www.databasejournal.com/features/mssql/article.php/3828341/Database-Mirroring-in-SQL-Server-2008.htm
****************************************************************
2.)Replication in SQL Server 2008
http://www.databasejournal.com/features/mssql/article.php/3820361/Peer-to-Peer-Replication-in-SQL-Server-2008--Add-a-node-and-resolve-conflict.htm
*****************************************************************
3.)get day from datetime
DATENAME ( datepart ,date )
http://msdn.microsoft.com/en-us/library/ms174395(SQL.90).aspx
******************************************************************
4.) Delete temp data from pc shortcut
run type:%temp%
16.2.10
validation in input upload
script type="text/javascript"
function Checkfiles(f){
f = f.elements;
if(/.*\.(gif)|(jpeg)|(jpg)|(doc)$/.test(f['filename'].value.toLowerCase()))
return true;
alert('Please Upload Gif or Jpg Images, or Doc Files Only.');
f['filename'].focus();
return false;
};
form action="#" onsubmit="return Checkfiles(this);"
input type="file" name="filename"
input type="submit" value="Go!"
http://www.dynamicdrive.com/forums/archive/index.php/t-37439.html
function Checkfiles(f){
f = f.elements;
if(/.*\.(gif)|(jpeg)|(jpg)|(doc)$/.test(f['filename'].value.toLowerCase()))
return true;
alert('Please Upload Gif or Jpg Images, or Doc Files Only.');
f['filename'].focus();
return false;
};
form action="#" onsubmit="return Checkfiles(this);"
input type="file" name="filename"
input type="submit" value="Go!"
http://www.dynamicdrive.com/forums/archive/index.php/t-37439.html
Download file code
// Get the physical Path of the file(test.doc)
string filepath = Server.MapPath("File/Demo.txt");
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo file = new FileInfo(filepath);
// Checking if file exists
if (file.Exists)
{
// Clear the content of the response
Response.ClearContent();
// LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
// Add the file size into the response header
Response.AddHeader("Content-Length", file.Length.ToString());
// Set the ContentType
Response.ContentType = ReturnExtension(file.Extension.ToLower());
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(file.FullName);
// End the response
Response.End();
}
******************************************************************************8
private string ReturnExtension(string fileExtension)
{
switch (fileExtension)
{
case ".htm":
case ".html":
case ".log":
return "text/HTML";
case ".txt":
return "text/plain";
case ".doc":
return "application/ms-word";
case ".tiff":
case ".tif":
return "image/tiff";
case ".asf":
return "video/x-ms-asf";
case ".avi":
return "video/avi";
case ".zip":
return "application/zip";
case ".xls":
case ".csv":
return "application/vnd.ms-excel";
case ".gif":
return "image/gif";
case ".jpg":
case "jpeg":
return "image/jpeg";
case ".bmp":
return "image/bmp";
case ".wav":
return "audio/wav";
case ".mp3":
return "audio/mpeg3";
case ".mpg":
case "mpeg":
return "video/mpeg";
case ".rtf":
return "application/rtf";
case ".asp":
return "text/asp";
case ".pdf":
return "application/pdf";
case ".fdf":
return "application/vnd.fdf";
case ".ppt":
return "application/mspowerpoint";
case ".dwg":
return "image/vnd.dwg";
case ".msg":
return "application/msoutlook";
case ".xml":
case ".sdxl":
return "application/xml";
case ".xdp":
return "application/vnd.adobe.xdp+xml";
default:
return "application/octet-stream";
}
}
string filepath = Server.MapPath("File/Demo.txt");
// Create New instance of FileInfo class to get the properties of the file being downloaded
FileInfo file = new FileInfo(filepath);
// Checking if file exists
if (file.Exists)
{
// Clear the content of the response
Response.ClearContent();
// LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
// Add the file size into the response header
Response.AddHeader("Content-Length", file.Length.ToString());
// Set the ContentType
Response.ContentType = ReturnExtension(file.Extension.ToLower());
// Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
Response.TransmitFile(file.FullName);
// End the response
Response.End();
}
******************************************************************************8
private string ReturnExtension(string fileExtension)
{
switch (fileExtension)
{
case ".htm":
case ".html":
case ".log":
return "text/HTML";
case ".txt":
return "text/plain";
case ".doc":
return "application/ms-word";
case ".tiff":
case ".tif":
return "image/tiff";
case ".asf":
return "video/x-ms-asf";
case ".avi":
return "video/avi";
case ".zip":
return "application/zip";
case ".xls":
case ".csv":
return "application/vnd.ms-excel";
case ".gif":
return "image/gif";
case ".jpg":
case "jpeg":
return "image/jpeg";
case ".bmp":
return "image/bmp";
case ".wav":
return "audio/wav";
case ".mp3":
return "audio/mpeg3";
case ".mpg":
case "mpeg":
return "video/mpeg";
case ".rtf":
return "application/rtf";
case ".asp":
return "text/asp";
case ".pdf":
return "application/pdf";
case ".fdf":
return "application/vnd.fdf";
case ".ppt":
return "application/mspowerpoint";
case ".dwg":
return "image/vnd.dwg";
case ".msg":
return "application/msoutlook";
case ".xml":
case ".sdxl":
return "application/xml";
case ".xdp":
return "application/vnd.adobe.xdp+xml";
default:
return "application/octet-stream";
}
}
15.2.10
Multiple Image Upload
http://www.asp.net/learn/videos/video-253.aspx
http://www.codeproject.com/KB/aspnet/FlashUpload.aspx
http://www.codeproject.com/KB/aspnet/FlashUpload.aspx
8.2.10
Iphone Integration in windows Os ( Asp.net c#)
http://forums.whirlpool.net.au/forum-replies-archive.cfm/1120070.html
http://shelastyle.net/blog/developing-for-iphone-with-c/
**********************************************************
http://monodevelop.com/Download
http://blog.testlabs.com/2009/09/hello-monotouch-net-and-c-developement.html
http://shelastyle.net/blog/developing-for-iphone-with-c/
**********************************************************
http://monodevelop.com/Download
http://blog.testlabs.com/2009/09/hello-monotouch-net-and-c-developement.html
5.2.10
XML(EXtensible Markup Language.) SERIALIZATION
http://vinbhat.wordpress.com/2008/08/19/exporting-data-creating-xml-files-using-c/
*****************************************************************************
http://www.stjhimy.com/2009/10/17/playing-around-with-xmls-and-xsds-net-smiles-for-you/
****************************************************************************
http://www.switchonthecode.com/tutorials/csharp-tutorial-xml-serialization
***
XmlSerializer serializer = new XmlSerializer(typeof(DES.DES));
TextWriter textWriter = new StreamWriter(_fileName);
serializer.Serialize(textWriter, objdes);
textWriter.Close();
*********************************************************************
http://www.csharper.net/blog/serializing_without_the_namespace__xmlns__xmlns_xsd__xmlns_xsi_.aspx
***
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(_fileName, settings))
{
XmlSerializer serializer = new XmlSerializer(typeof(DES.DES));
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add("", "http://www.mto.gov.on.ca/rus/des/batch-input");
serializer.Serialize(writer, objdes, namespaces);
}
*****************************************************************************
http://www.stjhimy.com/2009/10/17/playing-around-with-xmls-and-xsds-net-smiles-for-you/
****************************************************************************
http://www.switchonthecode.com/tutorials/csharp-tutorial-xml-serialization
***
XmlSerializer serializer = new XmlSerializer(typeof(DES.DES));
TextWriter textWriter = new StreamWriter(_fileName);
serializer.Serialize(textWriter, objdes);
textWriter.Close();
*********************************************************************
http://www.csharper.net/blog/serializing_without_the_namespace__xmlns__xmlns_xsd__xmlns_xsi_.aspx
***
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(_fileName, settings))
{
XmlSerializer serializer = new XmlSerializer(typeof(DES.DES));
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add("", "http://www.mto.gov.on.ca/rus/des/batch-input");
serializer.Serialize(writer, objdes, namespaces);
}
28.1.10
14.1.10
EmailMail Query
GO
/****** Object: StoredProcedure [dbo].[Mail]
10:16:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[Usp_MailHeadersGetAll]
@MessageType Char(3)='INB'
,@User_FK BIGINT=0
,@Email_FK BIGINT=0
,@datefrom varchar(15)=''
,@dateto varchar(15)=''
,@PageIndex int=1
,@RowsPerPage int=99999
,@HasAttachments Bit=0
,@IsRead bit=0
,@IsUnread bit =0
,@OrderBY smallint=4
,@Order smallint=2
as
BEGIN
Declare @strpaging as nvarchar(4000)
Declare @strqry as nvarchar(4000)
if(len(@MessageType)=3)
BEGIN
--PagingData
set @strpaging = 'SELECT count(header_pk) as ''TotalRecords'''
set @strpaging = @strpaging + ' FROM crm_mail_headers (nolock) INNER JOIN'
set @strpaging = @strpaging + ' crm_Mail_Action (nolock) ON crm_mail_headers.action_fk = crm_Mail_Action.action_pk '
set @strpaging = @strpaging + ' where crm_mail_headers.User_FK ='+ CAST(@User_FK as varchar) +' and crm_mail_headers.Email_FK ='+ CAST(@Email_FK as varchar)
if(@HasAttachments=1)
set @strpaging = @strpaging + ' and crm_mail_headers.HasAttachment =1 '
if(@IsRead=1)
set @strpaging = @strpaging + ' and crm_mail_headers.IsRead =1 '
if(@IsUnread=1)
set @strpaging = @strpaging + ' and crm_mail_headers.IsRead =0 '
if(@MessageType='INB')
set @strpaging = @strpaging + ' and crm_mail_headers.IsInbox =1 '
if(@MessageType='SNT')
set @strpaging = @strpaging + ' and crm_mail_headers.IsSent =1 '
if(@MessageType='DRA')
set @strpaging = @strpaging + ' and crm_mail_headers.IsDraft =1 '
if(@MessageType='SPA')
set @strpaging = @strpaging + ' and crm_mail_headers.IsSpam =1 '
if(@MessageType='TRA')
set @strpaging = @strpaging + ' and crm_mail_headers.IsDeleted =1 '
--ListData
set @strqry = 'SELECT * FROM '
set @strqry = @strqry + ' ( '
set @strqry = @strqry + ' SELECT ROW_NUMBER() OVER(ORDER BY header_pk desc) as RowNum ,header_pk,user_Fk,UniqueId,ReceivedDate,MessageId,HasAttachment,IsBodySaved,IsRead,ActionComment,'
set @strqry = @strqry + ' MessageFrom As Sender,Subject as Sub,action_fk,'
set @strqry = @strqry + ' Case IsRead When 0 then ''Images/new.jpg'' else ''Images/old.gif'' ENd as ''EMailStatus'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+MessageFrom+'''' else MessageFrom END as ''MessageFrom'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+isnull(MessageTo,'''')+'''' else isnull(MessageTo,'''') END as ''MessageTo'','
set @strqry = @strqry + ' Case HasAttachment When 1 then '''' else '' '' ENd as ''AttchmentStatus'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+Subject+'''' else Subject END as ''Subject'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+Action+'''' else Action END as ''Action'''
set @strqry = @strqry + ' FROM crm_mail_headers (nolock) INNER JOIN'
set @strqry = @strqry + ' crm_Mail_Action (nolock) ON crm_mail_headers.action_fk = crm_Mail_Action.action_pk '
set @strqry = @strqry + ' where crm_mail_headers.User_FK ='+ CAST(@User_FK as varchar) +' and crm_mail_headers.Email_FK ='+ CAST(@Email_FK as varchar)
if(@HasAttachments=1)
set @strqry = @strqry + ' and crm_mail_headers.HasAttachment =1 '
if(@IsRead=1)
set @strqry = @strqry + ' and crm_mail_headers.IsRead =1 '
if(@IsUnread=1)
set @strqry = @strqry + ' and crm_mail_headers.IsRead =0 '
if(@MessageType='INB')
set @strqry = @strqry + ' and crm_mail_headers.IsInbox =1 '
if(@MessageType='SNT')
set @strqry = @strqry + ' and crm_mail_headers.IsSent =1 '
if(@MessageType='DRA')
set @strqry = @strqry + ' and crm_mail_headers.IsDraft =1 '
if(@MessageType='SPA')
set @strqry = @strqry + ' and crm_mail_headers.IsSpam =1 '
if(@MessageType='TRA')
set @strqry = @strqry + ' and crm_mail_headers.IsDeleted =1 '
set @strqry = @strqry + ' ) as Mails'
set @strqry = @strqry + ' WHERE RowNum BETWEEN '+ cast(@PageIndex as varchar(100)) +' AND '+ cast( ((@PageIndex + @RowsPerPage) - 1) as varchar(100))
--Order By [Field]
if(@OrderBY=1)
set @strqry = @strqry + ' Order By ReceivedDate '
else if(@OrderBY=2)
set @strqry = @strqry + ' Order By Sender '
else if(@OrderBY=3)
set @strqry = @strqry + ' Order By Sub '
else if(@OrderBY=4)
set @strqry = @strqry + ' Order By ReceivedDate '
else if(@OrderBY=5)
set @strqry = @strqry + ' Order By Action '
else
set @strqry = @strqry + ' Order By header_pk '
--- OrderBy
if(@Order=1)
set @strqry = @strqry + ' ASC'
if(@Order=2)
set @strqry = @strqry + ' DESC'
END
EXECUTE sp_executesql @strpaging
EXECUTE sp_executesql @strqry
-- select @strqry
END
/****** Object: StoredProcedure [dbo].[Mail]
10:16:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Proc [dbo].[Usp_MailHeadersGetAll]
@MessageType Char(3)='INB'
,@User_FK BIGINT=0
,@Email_FK BIGINT=0
,@datefrom varchar(15)=''
,@dateto varchar(15)=''
,@PageIndex int=1
,@RowsPerPage int=99999
,@HasAttachments Bit=0
,@IsRead bit=0
,@IsUnread bit =0
,@OrderBY smallint=4
,@Order smallint=2
as
BEGIN
Declare @strpaging as nvarchar(4000)
Declare @strqry as nvarchar(4000)
if(len(@MessageType)=3)
BEGIN
--PagingData
set @strpaging = 'SELECT count(header_pk) as ''TotalRecords'''
set @strpaging = @strpaging + ' FROM crm_mail_headers (nolock) INNER JOIN'
set @strpaging = @strpaging + ' crm_Mail_Action (nolock) ON crm_mail_headers.action_fk = crm_Mail_Action.action_pk '
set @strpaging = @strpaging + ' where crm_mail_headers.User_FK ='+ CAST(@User_FK as varchar) +' and crm_mail_headers.Email_FK ='+ CAST(@Email_FK as varchar)
if(@HasAttachments=1)
set @strpaging = @strpaging + ' and crm_mail_headers.HasAttachment =1 '
if(@IsRead=1)
set @strpaging = @strpaging + ' and crm_mail_headers.IsRead =1 '
if(@IsUnread=1)
set @strpaging = @strpaging + ' and crm_mail_headers.IsRead =0 '
if(@MessageType='INB')
set @strpaging = @strpaging + ' and crm_mail_headers.IsInbox =1 '
if(@MessageType='SNT')
set @strpaging = @strpaging + ' and crm_mail_headers.IsSent =1 '
if(@MessageType='DRA')
set @strpaging = @strpaging + ' and crm_mail_headers.IsDraft =1 '
if(@MessageType='SPA')
set @strpaging = @strpaging + ' and crm_mail_headers.IsSpam =1 '
if(@MessageType='TRA')
set @strpaging = @strpaging + ' and crm_mail_headers.IsDeleted =1 '
--ListData
set @strqry = 'SELECT * FROM '
set @strqry = @strqry + ' ( '
set @strqry = @strqry + ' SELECT ROW_NUMBER() OVER(ORDER BY header_pk desc) as RowNum ,header_pk,user_Fk,UniqueId,ReceivedDate,MessageId,HasAttachment,IsBodySaved,IsRead,ActionComment,'
set @strqry = @strqry + ' MessageFrom As Sender,Subject as Sub,action_fk,'
set @strqry = @strqry + ' Case IsRead When 0 then ''Images/new.jpg'' else ''Images/old.gif'' ENd as ''EMailStatus'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+MessageFrom+'''' else MessageFrom END as ''MessageFrom'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+isnull(MessageTo,'''')+'''' else isnull(MessageTo,'''') END as ''MessageTo'','
set @strqry = @strqry + ' Case HasAttachment When 1 then '''' else '' '' ENd as ''AttchmentStatus'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+Subject+'''' else Subject END as ''Subject'','
set @strqry = @strqry + ' Case IsRead When 0 then ''''+Action+'''' else Action END as ''Action'''
set @strqry = @strqry + ' FROM crm_mail_headers (nolock) INNER JOIN'
set @strqry = @strqry + ' crm_Mail_Action (nolock) ON crm_mail_headers.action_fk = crm_Mail_Action.action_pk '
set @strqry = @strqry + ' where crm_mail_headers.User_FK ='+ CAST(@User_FK as varchar) +' and crm_mail_headers.Email_FK ='+ CAST(@Email_FK as varchar)
if(@HasAttachments=1)
set @strqry = @strqry + ' and crm_mail_headers.HasAttachment =1 '
if(@IsRead=1)
set @strqry = @strqry + ' and crm_mail_headers.IsRead =1 '
if(@IsUnread=1)
set @strqry = @strqry + ' and crm_mail_headers.IsRead =0 '
if(@MessageType='INB')
set @strqry = @strqry + ' and crm_mail_headers.IsInbox =1 '
if(@MessageType='SNT')
set @strqry = @strqry + ' and crm_mail_headers.IsSent =1 '
if(@MessageType='DRA')
set @strqry = @strqry + ' and crm_mail_headers.IsDraft =1 '
if(@MessageType='SPA')
set @strqry = @strqry + ' and crm_mail_headers.IsSpam =1 '
if(@MessageType='TRA')
set @strqry = @strqry + ' and crm_mail_headers.IsDeleted =1 '
set @strqry = @strqry + ' ) as Mails'
set @strqry = @strqry + ' WHERE RowNum BETWEEN '+ cast(@PageIndex as varchar(100)) +' AND '+ cast( ((@PageIndex + @RowsPerPage) - 1) as varchar(100))
--Order By [Field]
if(@OrderBY=1)
set @strqry = @strqry + ' Order By ReceivedDate '
else if(@OrderBY=2)
set @strqry = @strqry + ' Order By Sender '
else if(@OrderBY=3)
set @strqry = @strqry + ' Order By Sub '
else if(@OrderBY=4)
set @strqry = @strqry + ' Order By ReceivedDate '
else if(@OrderBY=5)
set @strqry = @strqry + ' Order By Action '
else
set @strqry = @strqry + ' Order By header_pk '
--- OrderBy
if(@Order=1)
set @strqry = @strqry + ' ASC'
if(@Order=2)
set @strqry = @strqry + ' DESC'
END
EXECUTE sp_executesql @strpaging
EXECUTE sp_executesql @strqry
-- select @strqry
END
Useful c#
classes,Overloading,Properties::
http://www.codeguru.com/csharp/csharp/cs_syntax/anandctutorials/article.php/c5829
=====================================================================================
Properties in c#:
http://www.devarticles.com/c/a/C-Sharp/Understanding-Properties-in-C-Sharp/
==============================================================================
http://www.devarticles.com/c/a/C-Sharp/Inheritance-and-Polymorphism/
http://www.devarticles.com/c/a/C-Sharp/Introduction-to-Objects-and-Classes-in-C-sharp/6/
http://www.sitepoint.com/article/dataset-datareader/
=========
Convert a DataReader to DataTable in ASP.NET
http://www.dotnetcurry.com/ShowArticle.aspx?ID=143
===========
Static Method::
http://forums.asp.net/t/1445372.aspx
Static CLass:;
http://msdn.microsoft.com/en-us/library/79b3xss3(VS.80).aspx
===========
abstract"
http://www.javacoffeebreak.com/faq/faq0084.html
================
difference between abstract class and interface::
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
========================
http://www.codeguru.com/csharp/csharp/cs_syntax/anandctutorials/article.php/c5829
=====================================================================================
Properties in c#:
http://www.devarticles.com/c/a/C-Sharp/Understanding-Properties-in-C-Sharp/
==============================================================================
http://www.devarticles.com/c/a/C-Sharp/Inheritance-and-Polymorphism/
http://www.devarticles.com/c/a/C-Sharp/Introduction-to-Objects-and-Classes-in-C-sharp/6/
http://www.sitepoint.com/article/dataset-datareader/
=========
Convert a DataReader to DataTable in ASP.NET
http://www.dotnetcurry.com/ShowArticle.aspx?ID=143
===========
Static Method::
http://forums.asp.net/t/1445372.aspx
Static CLass:;
http://msdn.microsoft.com/en-us/library/79b3xss3(VS.80).aspx
===========
abstract"
http://www.javacoffeebreak.com/faq/faq0084.html
================
difference between abstract class and interface::
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx
========================
Facebook asp.net
Event Master:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
public partial class EventMaster : System.Web.UI.MasterPage
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
}
protected void lnkEventPermission_Click(object sender, EventArgs e)
{
Response.Redirect(string.Format("http://www.facebook.com/authorize.php?api_key={0}&v=1.0&ext_perm={1}", "d768a2201d05348eef79b3dfcded6e8c", Enums.ExtendedPermissions.create_event));
}
}
====================================
create Event:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
public partial class CreateEvent : System.Web.UI.Page
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
try
{
DateTime CurrentDate = System.DateTime.Now;
DateTime ChkStartDate = Convert.ToDateTime(txtStartDate.Text);
if (ChkStartDate < CurrentDate)
{
lblMsg.Text = "Start date Should be greater than or eqaual to current date";
return;
}
lblMsg.Text = txtEndDate.Text;
FacebookAPI = new Api(ConnectSession);
DateTime StartDate = new DateTime();
StartDate = Convert.ToDateTime(txtStartDate.Text);
DateTime EndDate = new DateTime();
EndDate = Convert.ToDateTime(txtEndDate.Text);
var NewEvent = new facebookevent
{
name = txtname.Text,
description = txtdescription.Text,
location = txtLocation.Text,
host = txtHost.Text,
event_type = txtType.Text,
event_subtype = txtSubType.Text
};
//AddHours(8) is in below line because of the difference in time between my server and Facebook server you can adjust it as per requirement.
NewEvent.start_time = DateHelper.ConvertDateToFacebookDate(new DateTime(StartDate.Year, StartDate.Month, StartDate.Day, Convert.ToInt32(drpStartSession.SelectedItem.Value) + Convert.ToInt32(drpStartTime.SelectedItem.Value) , Convert.ToInt32(DrpMinuteStart.SelectedItem.Value), 0).AddHours(8));
NewEvent.end_time = DateHelper.ConvertDateToFacebookDate(new DateTime(EndDate.Year, EndDate.Month, EndDate.Day, Convert.ToInt32(drpEndSession.SelectedItem.Value) + Convert.ToInt32(drpEndTime.SelectedItem.Value) , Convert.ToInt32(drpMinuteEnd.SelectedItem.Value), 0).AddHours(8));
long NewEventId = FacebookAPI.Events.Create(NewEvent);
lblMsg.Text = string.Format("Event ({0}) Created Successfully.", NewEventId);
}
catch (Exception err)
{
lblMsg.Text = err.Message;
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
txtEndDate.Text = "";
txtdescription.Text = "";
txtHost.Text = "";
txtLocation.Text = "";
txtname.Text = "";
txtStartDate.Text = "";
txtSubType.Text = "";
txtType.Text = "";
}
protected void imgBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("Default.aspx");
}
}
=======================================
edit Event:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
using System.Collections;
public partial class EditEvent : System.Web.UI.Page
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
long EventId;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
if (!IsPostBack)
{
//Function to get information about the current information about selected event for editing
GetEventAsperEid();
}
}
private void GetEventAsperEid()
{
try
{
Hashtable EventInfo = new Hashtable();
EventInfo = (Hashtable)(Session["SesEventInfo"]);
lbEid.Text = EventInfo["EventId"].ToString();
lblname.Text = EventInfo["Name"].ToString();
txtStartDate.Text = EventInfo["StartTime"].ToString();
txtEndDate.Text = EventInfo["EndTime"].ToString();
txtdescription.Text = EventInfo["Description"].ToString();
txtLocation.Text = EventInfo["Location"].ToString();
txtHost.Text = EventInfo["Host"].ToString();
}
catch
{
}
}
protected void imgCreate_Click(object sender, ImageClickEventArgs e)
{
try
{
DateTime CurrentDate = System.DateTime.Now;
DateTime ChkStartDate = Convert.ToDateTime(txtStartDate.Text);
if (ChkStartDate < CurrentDate)
{
lblMsg.Text = "Start date Should be greater than or eqaual to current date";
return;
}
Hashtable EventInfo = new Hashtable();
EventInfo = (Hashtable)(Session["SesEventInfo"]);
EventId = Convert.ToInt64(EventInfo["EventId"].ToString());
FacebookAPI = new Api(ConnectSession);
DateTime StartDate = new DateTime();
StartDate = Convert.ToDateTime(txtStartDate.Text);
DateTime EndDate = new DateTime();
EndDate = Convert.ToDateTime(txtEndDate.Text);
var NewEvent = new facebookevent
{
name = lblname.Text,
description = txtdescription.Text,
location = txtLocation.Text,
host = txtHost.Text,
event_type = txtType.Text,
event_subtype = txtSubType.Text
};
//AddHours(8) is in below line because of the difference in time between my server and Facebook server you can adjust it as per requirement.
NewEvent.start_time = DateHelper.ConvertDateToFacebookDate(new DateTime(StartDate.Year, StartDate.Month, StartDate.Day, Convert.ToInt32(drpStartSession.SelectedItem.Value)+ Convert.ToInt32( drpStartTime.SelectedItem.Value), Convert.ToInt32(DrpMinuteStart.SelectedItem.Value), 0).AddHours(8));
NewEvent.end_time = DateHelper.ConvertDateToFacebookDate(new DateTime(EndDate.Year, EndDate.Month, EndDate.Day, Convert.ToInt32(drpEndSession.SelectedItem.Value) + Convert.ToInt32(drpEndTime.SelectedItem.Value), Convert.ToInt32(drpMinuteEnd.SelectedItem.Value), 0).AddHours(8));
bool NewEventId = FacebookAPI.Events.Edit(EventId, NewEvent);
lblMsg.Text = string.Format("Event ({0}) Updated Successfully.", NewEventId);
}
catch (Exception err)
{
lblMsg.Text = err.Message;
}
}
protected void imgRefresh_Click(object sender, ImageClickEventArgs e)
{
lbEid.Text = "";
txtEndDate.Text = "";
txtdescription.Text = "";
txtHost.Text = "";
txtLocation.Text = "";
lblname.Text = "";
txtStartDate.Text = "";
txtSubType.Text = "";
txtType.Text = "";
}
protected void imgBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("Default.aspx");
}
}
=======================================
Default page:;
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections;
using Facebook;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
public partial class Default : Facebook.Web.CanvasFBMLBasePage
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
user FaceBookUser;
string AuthToken;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
AuthToken = Request.QueryString["auth_token"];
if (String.IsNullOrEmpty(AuthToken))
{
Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + "d768a2201d05348eef79b3dfcded6e8c" + @"&v=0.4\");
}
else
{
try
{
FacebookAPI = new Api(ConnectSession);
if (!IsPostBack)
{
//Functoin to get current user information.
FaceBookCurrentUser();
//Function to get events
FaceBookEvents();
//Function to get friend list
FacebookFriends();
}
}
catch(Exception err)
{
lblMessage.Text = "Please click connect button.";
}
}
}
private void FaceBookCurrentUser()
{
long uid = FacebookAPI.Users.GetLoggedInUser();
FaceBookUser = FacebookAPI.Users.GetInfo(uid);
lblUserFName.Text = FaceBookUser.first_name;
lblUserLName.Text = FaceBookUser.last_name;
lblDob.Text = FaceBookUser.birthday;
}
private void FaceBookEvents()
{
List LstPrpEventObj = new List();
IList EventList = FacebookAPI.Events.Get();
int i = 1;
foreach (facebookevent EventInList in EventList)
{
prpEvents ObjPrpevents = new prpEvents();
ObjPrpevents.EventId = EventInList.eid;
ObjPrpevents.EventNo = i.ToString();
ObjPrpevents.Name = EventInList.name.ToString();
ObjPrpevents.StartDate = EventInList.start_date.ToString();
ObjPrpevents.StartTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.start_time).ToString();
ObjPrpevents.EndTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.end_time).ToString();
ObjPrpevents.EndDate = EventInList.end_date.ToString();
ObjPrpevents.Description = EventInList.description.ToString();
ObjPrpevents.Location = EventInList.location.ToString();
ObjPrpevents.Host = EventInList.host.ToString();
i++;
LstPrpEventObj.Add(ObjPrpevents);
}
GrdEvent.DataSource = LstPrpEventObj;
GrdEvent.DataBind();
}
private void FacebookFriends()
{
IList MyFriendList = FacebookAPI.Friends.GetUserObjects();
List LstPrpFriendsObj = new List();
foreach (var Friend in MyFriendList)
{
prpfriends ObjPrpFriends = new prpfriends();
ObjPrpFriends.Dob = Friend.birthday;
ObjPrpFriends.Name = Friend.name;
ObjPrpFriends.RelationshipStatus = Friend.relationship_status;
ObjPrpFriends.Sex = Friend.sex;
LstPrpFriendsObj.Add(ObjPrpFriends);
}
rptrFriends.DataSource = LstPrpFriendsObj;
rptrFriends.DataBind();
lblrptrfriendsCount.Text = rptrFriends.Items.Count.ToString();
}
protected void GrdEvent_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
GrdEvent.PageIndex = e.NewPageIndex;
FaceBookEvents();
}
catch (Exception err)
{
lblMessage.Text = err.Message;
}
}
protected void btnCreateEvent_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("CreateEvent.aspx");
}
protected void GrdEvent_SelectedIndexChanged(object sender, EventArgs e)
{
long EventId = Convert.ToInt64(GrdEvent.SelectedDataKey.Value);
try
{
List LstEid = new List();
LstEid.Add(EventId);
IList EventList = FacebookAPI.Events.Get(LstEid);
//selected event Information saved in session "SesEventInfo" to get it on edit page.
foreach (facebookevent EventInList in EventList)
{
string[] StrStartTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.start_time).ToString().Split(' ');
string[] StrEndTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.end_time).ToString().Split(' ');
Hashtable EventInfo = new Hashtable();
EventInfo.Add("EventId", EventId);
EventInfo.Add("Name", EventInList.name);
EventInfo.Add("StartTime", StrStartTime[0].ToString());
EventInfo.Add("EndTime", StrEndTime[0].ToString());
EventInfo.Add("Description", EventInList.description.ToString());
EventInfo.Add("Location", EventInList.location.ToString());
EventInfo.Add("Host", EventInList.host.ToString());
Session["SesEventInfo"] = EventInfo;
}
}
catch (Exception err)
{
lblMessage.Text = err.Message;
}
Response.Redirect("EditEvent.aspx?Eid=" + EventId );
}
protected void GrdEvent_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
long EventId = Convert.ToInt64(GrdEvent.DataKeys[e.RowIndex].Value);
FacebookAPI.Events.Cancel(EventId, "Cancel this message");
lblMessage.Text = "Event Canceled";
FaceBookEvents();
}
catch
{
}
}
}
//Property class for "FacebookFriends" function.
public class prpfriends
{
private String prpName, prpDob, prpRelationshipStatus,prpSex;
public string Name
{
get
{
return prpName;
}
set
{
prpName = value;
}
}
public string Dob
{
get
{
return prpDob;
}
set
{
prpDob = value;
}
}
public string RelationshipStatus
{
get
{
return prpRelationshipStatus;
}
set
{
prpRelationshipStatus = value;
}
}
public string Sex
{
get
{
return prpSex;
}
set
{
prpSex = value;
}
}
}
//Property class for "FaceBookEvents" function.
public class prpEvents
{
private String prpName, prpHost, prpStartDate, prpStartTime, prpEndDate, prpEndTime, prpEventNo, prpDescription,prpLocation;
private long prpEventId;
public long EventId
{
get
{
return prpEventId;
}
set
{
prpEventId = value;
}
}
public string EventNo
{
get
{
return prpEventNo;
}
set
{
prpEventNo = value;
}
}
public string Name
{
get
{
return prpName;
}
set
{
prpName = value;
}
}
public string Host
{
get
{
return prpHost;
}
set
{
prpHost = value;
}
}
public string StartDate
{
get
{
return prpStartDate;
}
set
{
prpStartDate = value;
}
}
public string StartTime
{
get
{
return prpStartTime;
}
set
{
prpStartTime = value;
}
}
public string EndDate
{
get
{
return prpEndDate;
}
set
{
prpEndDate = value;
}
}
public string EndTime
{
get
{
return prpEndTime;
}
set
{
prpEndTime = value;
}
}
public string Description
{
get
{
return prpDescription;
}
set
{
prpDescription = value;
}
}
public string Location
{
get
{
return prpLocation;
}
set
{
prpLocation = value;
}
}
}
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
public partial class EventMaster : System.Web.UI.MasterPage
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
}
protected void lnkEventPermission_Click(object sender, EventArgs e)
{
Response.Redirect(string.Format("http://www.facebook.com/authorize.php?api_key={0}&v=1.0&ext_perm={1}", "d768a2201d05348eef79b3dfcded6e8c", Enums.ExtendedPermissions.create_event));
}
}
====================================
create Event:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
public partial class CreateEvent : System.Web.UI.Page
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
try
{
DateTime CurrentDate = System.DateTime.Now;
DateTime ChkStartDate = Convert.ToDateTime(txtStartDate.Text);
if (ChkStartDate < CurrentDate)
{
lblMsg.Text = "Start date Should be greater than or eqaual to current date";
return;
}
lblMsg.Text = txtEndDate.Text;
FacebookAPI = new Api(ConnectSession);
DateTime StartDate = new DateTime();
StartDate = Convert.ToDateTime(txtStartDate.Text);
DateTime EndDate = new DateTime();
EndDate = Convert.ToDateTime(txtEndDate.Text);
var NewEvent = new facebookevent
{
name = txtname.Text,
description = txtdescription.Text,
location = txtLocation.Text,
host = txtHost.Text,
event_type = txtType.Text,
event_subtype = txtSubType.Text
};
//AddHours(8) is in below line because of the difference in time between my server and Facebook server you can adjust it as per requirement.
NewEvent.start_time = DateHelper.ConvertDateToFacebookDate(new DateTime(StartDate.Year, StartDate.Month, StartDate.Day, Convert.ToInt32(drpStartSession.SelectedItem.Value) + Convert.ToInt32(drpStartTime.SelectedItem.Value) , Convert.ToInt32(DrpMinuteStart.SelectedItem.Value), 0).AddHours(8));
NewEvent.end_time = DateHelper.ConvertDateToFacebookDate(new DateTime(EndDate.Year, EndDate.Month, EndDate.Day, Convert.ToInt32(drpEndSession.SelectedItem.Value) + Convert.ToInt32(drpEndTime.SelectedItem.Value) , Convert.ToInt32(drpMinuteEnd.SelectedItem.Value), 0).AddHours(8));
long NewEventId = FacebookAPI.Events.Create(NewEvent);
lblMsg.Text = string.Format("Event ({0}) Created Successfully.", NewEventId);
}
catch (Exception err)
{
lblMsg.Text = err.Message;
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
txtEndDate.Text = "";
txtdescription.Text = "";
txtHost.Text = "";
txtLocation.Text = "";
txtname.Text = "";
txtStartDate.Text = "";
txtSubType.Text = "";
txtType.Text = "";
}
protected void imgBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("Default.aspx");
}
}
=======================================
edit Event:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
using System.Collections;
public partial class EditEvent : System.Web.UI.Page
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
long EventId;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
if (!IsPostBack)
{
//Function to get information about the current information about selected event for editing
GetEventAsperEid();
}
}
private void GetEventAsperEid()
{
try
{
Hashtable EventInfo = new Hashtable();
EventInfo = (Hashtable)(Session["SesEventInfo"]);
lbEid.Text = EventInfo["EventId"].ToString();
lblname.Text = EventInfo["Name"].ToString();
txtStartDate.Text = EventInfo["StartTime"].ToString();
txtEndDate.Text = EventInfo["EndTime"].ToString();
txtdescription.Text = EventInfo["Description"].ToString();
txtLocation.Text = EventInfo["Location"].ToString();
txtHost.Text = EventInfo["Host"].ToString();
}
catch
{
}
}
protected void imgCreate_Click(object sender, ImageClickEventArgs e)
{
try
{
DateTime CurrentDate = System.DateTime.Now;
DateTime ChkStartDate = Convert.ToDateTime(txtStartDate.Text);
if (ChkStartDate < CurrentDate)
{
lblMsg.Text = "Start date Should be greater than or eqaual to current date";
return;
}
Hashtable EventInfo = new Hashtable();
EventInfo = (Hashtable)(Session["SesEventInfo"]);
EventId = Convert.ToInt64(EventInfo["EventId"].ToString());
FacebookAPI = new Api(ConnectSession);
DateTime StartDate = new DateTime();
StartDate = Convert.ToDateTime(txtStartDate.Text);
DateTime EndDate = new DateTime();
EndDate = Convert.ToDateTime(txtEndDate.Text);
var NewEvent = new facebookevent
{
name = lblname.Text,
description = txtdescription.Text,
location = txtLocation.Text,
host = txtHost.Text,
event_type = txtType.Text,
event_subtype = txtSubType.Text
};
//AddHours(8) is in below line because of the difference in time between my server and Facebook server you can adjust it as per requirement.
NewEvent.start_time = DateHelper.ConvertDateToFacebookDate(new DateTime(StartDate.Year, StartDate.Month, StartDate.Day, Convert.ToInt32(drpStartSession.SelectedItem.Value)+ Convert.ToInt32( drpStartTime.SelectedItem.Value), Convert.ToInt32(DrpMinuteStart.SelectedItem.Value), 0).AddHours(8));
NewEvent.end_time = DateHelper.ConvertDateToFacebookDate(new DateTime(EndDate.Year, EndDate.Month, EndDate.Day, Convert.ToInt32(drpEndSession.SelectedItem.Value) + Convert.ToInt32(drpEndTime.SelectedItem.Value), Convert.ToInt32(drpMinuteEnd.SelectedItem.Value), 0).AddHours(8));
bool NewEventId = FacebookAPI.Events.Edit(EventId, NewEvent);
lblMsg.Text = string.Format("Event ({0}) Updated Successfully.", NewEventId);
}
catch (Exception err)
{
lblMsg.Text = err.Message;
}
}
protected void imgRefresh_Click(object sender, ImageClickEventArgs e)
{
lbEid.Text = "";
txtEndDate.Text = "";
txtdescription.Text = "";
txtHost.Text = "";
txtLocation.Text = "";
lblname.Text = "";
txtStartDate.Text = "";
txtSubType.Text = "";
txtType.Text = "";
}
protected void imgBack_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("Default.aspx");
}
}
=======================================
Default page:;
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections;
using Facebook;
using Facebook.Rest;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Utility;
public partial class Default : Facebook.Web.CanvasFBMLBasePage
{
private const string FACEBOOK_API_KEY = "d768a2201d05348eef79b3dfcded6e8c";
private const string FACEBOOK_SECRET = "30efc267bdf2f8675a33d3920129dfbc";
private Api FacebookAPI;
user FaceBookUser;
string AuthToken;
private ConnectSession ConnectSession;
protected void Page_Load(object sender, EventArgs e)
{
ConnectSession = new ConnectSession(FACEBOOK_API_KEY, FACEBOOK_SECRET);
AuthToken = Request.QueryString["auth_token"];
if (String.IsNullOrEmpty(AuthToken))
{
Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + "d768a2201d05348eef79b3dfcded6e8c" + @"&v=0.4\");
}
else
{
try
{
FacebookAPI = new Api(ConnectSession);
if (!IsPostBack)
{
//Functoin to get current user information.
FaceBookCurrentUser();
//Function to get events
FaceBookEvents();
//Function to get friend list
FacebookFriends();
}
}
catch(Exception err)
{
lblMessage.Text = "Please click connect button.";
}
}
}
private void FaceBookCurrentUser()
{
long uid = FacebookAPI.Users.GetLoggedInUser();
FaceBookUser = FacebookAPI.Users.GetInfo(uid);
lblUserFName.Text = FaceBookUser.first_name;
lblUserLName.Text = FaceBookUser.last_name;
lblDob.Text = FaceBookUser.birthday;
}
private void FaceBookEvents()
{
List
IList
int i = 1;
foreach (facebookevent EventInList in EventList)
{
prpEvents ObjPrpevents = new prpEvents();
ObjPrpevents.EventId = EventInList.eid;
ObjPrpevents.EventNo = i.ToString();
ObjPrpevents.Name = EventInList.name.ToString();
ObjPrpevents.StartDate = EventInList.start_date.ToString();
ObjPrpevents.StartTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.start_time).ToString();
ObjPrpevents.EndTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.end_time).ToString();
ObjPrpevents.EndDate = EventInList.end_date.ToString();
ObjPrpevents.Description = EventInList.description.ToString();
ObjPrpevents.Location = EventInList.location.ToString();
ObjPrpevents.Host = EventInList.host.ToString();
i++;
LstPrpEventObj.Add(ObjPrpevents);
}
GrdEvent.DataSource = LstPrpEventObj;
GrdEvent.DataBind();
}
private void FacebookFriends()
{
IList
List
foreach (var Friend in MyFriendList)
{
prpfriends ObjPrpFriends = new prpfriends();
ObjPrpFriends.Dob = Friend.birthday;
ObjPrpFriends.Name = Friend.name;
ObjPrpFriends.RelationshipStatus = Friend.relationship_status;
ObjPrpFriends.Sex = Friend.sex;
LstPrpFriendsObj.Add(ObjPrpFriends);
}
rptrFriends.DataSource = LstPrpFriendsObj;
rptrFriends.DataBind();
lblrptrfriendsCount.Text = rptrFriends.Items.Count.ToString();
}
protected void GrdEvent_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
GrdEvent.PageIndex = e.NewPageIndex;
FaceBookEvents();
}
catch (Exception err)
{
lblMessage.Text = err.Message;
}
}
protected void btnCreateEvent_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("CreateEvent.aspx");
}
protected void GrdEvent_SelectedIndexChanged(object sender, EventArgs e)
{
long EventId = Convert.ToInt64(GrdEvent.SelectedDataKey.Value);
try
{
List
LstEid.Add(EventId);
IList
//selected event Information saved in session "SesEventInfo" to get it on edit page.
foreach (facebookevent EventInList in EventList)
{
string[] StrStartTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.start_time).ToString().Split(' ');
string[] StrEndTime = DateHelper.ConvertUnixTimeToDateTime(EventInList.end_time).ToString().Split(' ');
Hashtable EventInfo = new Hashtable();
EventInfo.Add("EventId", EventId);
EventInfo.Add("Name", EventInList.name);
EventInfo.Add("StartTime", StrStartTime[0].ToString());
EventInfo.Add("EndTime", StrEndTime[0].ToString());
EventInfo.Add("Description", EventInList.description.ToString());
EventInfo.Add("Location", EventInList.location.ToString());
EventInfo.Add("Host", EventInList.host.ToString());
Session["SesEventInfo"] = EventInfo;
}
}
catch (Exception err)
{
lblMessage.Text = err.Message;
}
Response.Redirect("EditEvent.aspx?Eid=" + EventId );
}
protected void GrdEvent_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
long EventId = Convert.ToInt64(GrdEvent.DataKeys[e.RowIndex].Value);
FacebookAPI.Events.Cancel(EventId, "Cancel this message");
lblMessage.Text = "Event Canceled";
FaceBookEvents();
}
catch
{
}
}
}
//Property class for "FacebookFriends" function.
public class prpfriends
{
private String prpName, prpDob, prpRelationshipStatus,prpSex;
public string Name
{
get
{
return prpName;
}
set
{
prpName = value;
}
}
public string Dob
{
get
{
return prpDob;
}
set
{
prpDob = value;
}
}
public string RelationshipStatus
{
get
{
return prpRelationshipStatus;
}
set
{
prpRelationshipStatus = value;
}
}
public string Sex
{
get
{
return prpSex;
}
set
{
prpSex = value;
}
}
}
//Property class for "FaceBookEvents" function.
public class prpEvents
{
private String prpName, prpHost, prpStartDate, prpStartTime, prpEndDate, prpEndTime, prpEventNo, prpDescription,prpLocation;
private long prpEventId;
public long EventId
{
get
{
return prpEventId;
}
set
{
prpEventId = value;
}
}
public string EventNo
{
get
{
return prpEventNo;
}
set
{
prpEventNo = value;
}
}
public string Name
{
get
{
return prpName;
}
set
{
prpName = value;
}
}
public string Host
{
get
{
return prpHost;
}
set
{
prpHost = value;
}
}
public string StartDate
{
get
{
return prpStartDate;
}
set
{
prpStartDate = value;
}
}
public string StartTime
{
get
{
return prpStartTime;
}
set
{
prpStartTime = value;
}
}
public string EndDate
{
get
{
return prpEndDate;
}
set
{
prpEndDate = value;
}
}
public string EndTime
{
get
{
return prpEndTime;
}
set
{
prpEndTime = value;
}
}
public string Description
{
get
{
return prpDescription;
}
set
{
prpDescription = value;
}
}
public string Location
{
get
{
return prpLocation;
}
set
{
prpLocation = value;
}
}
}
Subscribe to:
Posts (Atom)