[script]
// Just add this script to the header
function showDown(evt) {
evt = (evt) ? evt : ((event) ? event : null);
if (evt) {
if (event.keyCode == 8 && (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type !=
"password")) {
// When backspace is pressed but not in form element
cancelKey(evt);
}
else if (event.keyCode == 116) {
// When F5 is pressed
cancelKey(evt);
}
else if (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 82)) {
// When ctrl is pressed with R or N
cancelKey(evt);
}
}
}
function cancelKey(evt) {
if (evt.preventDefault) {
evt.preventDefault();
return false;
}
else {
evt.keyCode = 0;
evt.returnValue = false;
}
}
// Additional code for NS
if (navigator.appName=="Netscape") {
document.addEventListener("keypress",showDown,true);
}
document.onkeydown = showDown;
[/script]
Sunday, August 31, 2008
Saturday, August 23, 2008
java script for creating numeric text box
Hi,
This script is used for creating text box which will take only intergers as input.
function checkIt(evt) {
var lblmsg = document.getElementById('lblmainphone');
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
if (charCode ] 31 && (charCode [ 48 || charCode ] 57)) {
status = "This field accepts numbers only."
lblmsg.innerHTML = "This field accepts numbers only.";
return false
}
status = ""
lblmsg.innerHTML = "";
return true
}
how to call in text box.
[asp:TextBox ID="txtabtHomeMorgTerm" runat="server" CssClass="inputbox" onKeyPress="return checkIt(event)"][/asp:TextBox]
Thanks
HelpOnDeskTeam
This script is used for creating text box which will take only intergers as input.
function checkIt(evt) {
var lblmsg = document.getElementById('lblmainphone');
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
if (charCode ] 31 && (charCode [ 48 || charCode ] 57)) {
status = "This field accepts numbers only."
lblmsg.innerHTML = "This field accepts numbers only.";
return false
}
status = ""
lblmsg.innerHTML = "";
return true
}
how to call in text box.
[asp:TextBox ID="txtabtHomeMorgTerm" runat="server" CssClass="inputbox" onKeyPress="return checkIt(event)"][/asp:TextBox]
Thanks
HelpOnDeskTeam
Thursday, August 21, 2008
Custom paging as google stylye paging
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 BusenessLogic;
using BusenessObject;
public partial class MaheshPagingWithHelpofsanjeev : System.Web.UI.Page
{
BusenessObject.CustomPagingBo oCustomPaging = new CustomPagingBo();
int UserId = 1;
int PageSize = 1;
// static int TotalRows;
int GridCurrentPageIndex;
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["GridCurrentPageIndex"] != null && ViewState["GridCurrentPageIndex"].ToString() != "")
{
GridCurrentPageIndex = Convert.ToInt32(ViewState["GridCurrentPageIndex"]);
//LinkButton btnPrePage_Top = Page.FindControl("btnPrePage_Top") as LinkButton;
// btnPrePage_Top.Enabled = true;
}
else
{
GridCurrentPageIndex = 1;
// LinkButton btnPrePage_Top = Page.FindControl("btnPrePage_Top") as LinkButton;
// btnPrePage_Top.Enabled = false;
}
DisplayBottomPageLinks();
}
protected void DisplayBottomPageLinks()
{
if (ViewState["GridCurrentPageIndex"] != null && ViewState["GridCurrentPageIndex"].ToString() != "")
{
GridCurrentPageIndex = Convert.ToInt32(ViewState["GridCurrentPageIndex"]);
}
else
{
GridCurrentPageIndex = 1;
}
// Following code is used for the Gridview paging
Int32 count;
int showPages = 3;// 4; or 5 or 6 as you want (This is the key variable...)
//The variable showPages is used to show the no. of Pages you want to show at One time on the page..
LinkButton lnk;
Panel pnlPaging = Page.FindControl("pnlPaging") as Panel;
pnlPaging.Controls.Clear();
count = Convert.ToInt32(ViewState["count"]);
int pageSize = 1;
int totalPages = count / pageSize;
if (count % pageSize > 0)
{
totalPages += 1;
}
if (totalPages > 1)
{
for (int i = 0; i < totalPages; i++)
{
int pageNo = i + 1;
if (i != (GridCurrentPageIndex - 1))
{
if (i <= showPages)
{
if (i != showPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + pageNo.ToString();
lnk.Text = pageNo.ToString() + " ";
lnk.CausesValidation = false;
lnk.CommandArgument = pageNo.ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = pageNo.ToString();
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
if (i == showPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + pageNo.ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = pageNo.ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = pageNo.ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
if (GridCurrentPageIndex > showPages)
{
int x;
pnlPaging.Controls.Clear();
lnk = new LinkButton();
lnk.ID = "linkpage1";
lnk.Text = " << ";
lnk.CausesValidation = false;
lnk.CommandArgument = "1";
lnk.CommandName = "Paging_click";
lnk.ToolTip = "1";
//lnk.CssClass = "Paging";
lnk.Command += new CommandEventHandler(lnk_Command);
pnlPaging.Controls.Add(lnk);
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex - 1).ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex - 1).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex - 1).ToString();
lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
for (x = 0; x < showPages; x++)
{
if ((GridCurrentPageIndex + x) < totalPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex + x).ToString();
lnk.Text = (GridCurrentPageIndex + x).ToString() + " ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex + x).ToString();
lnk.CommandName = "Paging_click";
lnk.ToolTip = (GridCurrentPageIndex + x).ToString(); ;
lnk.Command += new CommandEventHandler(lnk_Command);
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
if (x == showPages && (GridCurrentPageIndex + x) <= totalPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex + x).ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex + x).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex + x).ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
if (i == (totalPages - 1) && (GridCurrentPageIndex != totalPages) && (totalPages > (showPages + 1)))
{
lnk = new LinkButton();
lnk.ID = "linkpage1" + totalPages.ToString();
lnk.Text = " >> ";
lnk.CausesValidation = false;
lnk.CommandArgument = totalPages.ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = totalPages.ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
if ((GridCurrentPageIndex == totalPages) && (totalPages > (showPages + 1)))
{
int x;
pnlPaging.Controls.Clear();
lnk = new LinkButton();
lnk.ID = "linkpage1";
lnk.Text = " << ";
lnk.CausesValidation = false;
lnk.CommandArgument = "1";
lnk.CommandName = "Paging_click";
lnk.ToolTip = "1";
lnk.Command += new CommandEventHandler(lnk_Command);
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex - showPages).ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex - showPages).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex - showPages).ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
for (x = (showPages - 1); x > 0; x--)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex - x).ToString();
lnk.Text = (GridCurrentPageIndex - x).ToString() + " ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex - x).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex - x).ToString();
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
}
else
{
if (i == (GridCurrentPageIndex - 1))
{
lnk = new LinkButton();
lnk.ID = "linkpage" + pageNo.ToString();
lnk.Text = pageNo.ToString() + " ";
lnk.CausesValidation = false;
lnk.ToolTip = pageNo.ToString();
//lnk.Attributes["OnClick"] = "return false;";
lnk.Enabled = false;
//lnk.ForeColor = System.Drawing.Color.Gray;
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
}
}
}
protected void click_PreviousPage(object sender, EventArgs e)
{
GridCurrentPageIndex = GridCurrentPageIndex - 1;
Searching();
DisplayBottomPageLinks();
}
void lnk_Command(Object sender, CommandEventArgs e)
{
Panel pnlPaging = (Panel)Page.FindControl("pnlPaging");
ViewState["linkId"] = e.CommandArgument.ToString();
if (e.CommandName == "FirstPaging_click")
{
GridCurrentPageIndex = Convert.ToInt32(e.CommandArgument);
ViewState["GridCurrentPageIndex"] = GridCurrentPageIndex;
}
else if (e.CommandName == "Paging_click")
{
GridCurrentPageIndex = Convert.ToInt32(e.CommandArgument);
ViewState["GridCurrentPageIndex"] = GridCurrentPageIndex;
}
Searching();
LinkButton lnk = (LinkButton)pnlPaging.FindControl("linkpage" + ViewState["linkId"].ToString());
lnk.Enabled = false;
if (GridCurrentPageIndex == 1)
{
// LinkButton btnPrePage_Top = Page.FindControl("btnPrePage_Top") as LinkButton;
// btnPrePage_Top.Enabled = false;
}
}
protected void BtnShowUser_Click(object sender, EventArgs e)
{
Searching();
}
public void Searching()
{
ViewState["imgClick"] = "Image_Search";
oCustomPaging.Uid = UserId;
oCustomPaging.GridPageSize = PageSize;
oCustomPaging.GridCurrentPageIndex = GridCurrentPageIndex;
DisplayUser();
}
public void DisplayUser()
{
DataList1.DataSource = CustomPagingBl.GetImageData(oCustomPaging);
DataList1.DataBind();
ViewState["count"] = oCustomPaging.TotalRecords;
if (ViewState["GridCurrentPageIndex"] != null && ViewState["GridCurrentPageIndex"].ToString() != "")
{
GridCurrentPageIndex = Convert.ToInt32(ViewState["GridCurrentPageIndex"]);
}
else
{
GridCurrentPageIndex = 1;
}
DisplayBottomPageLinks();
}
#region sp used for paging
/*
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROC [dbo].[USP_DEMO_PAGING]
(
@UID INT,
@GridCurrentPageIndex INT,
@GridPageSize INT
)
AS
BEGIN
DECLARE @LastDisplayingRecordIndex int -- To store the index number of last displayed records in Grid in .NET page. For next page it will start by increment last index by 1.
DECLARE @MaxDisplayingRecordIndex int -- To store upto which index records should be display.
SET @LastDisplayingRecordIndex = @GridPageSize * (@GridCurrentPageIndex-1)
SET @MaxDisplayingRecordIndex = @GridPageSize * @GridCurrentPageIndex
-- VARIABLE DECLARATION FOR DYNAMIC QUERY PARTS TO BE USED IN PAGING
DECLARE @SelectQueryWhere varchar(500)-- Used to put the condtion of lower and higher record index
DECLARE @QueryCount varchar(max) -- Used to count the total records.
DECLARE @SelectMainQuery varchar(500) -- To store the selected column part of the SELECT statement
DECLARE @SelectMainQueryResultSet varchar(7000) -- To store the result set query with Row_Number
DECLARE @SelectWhereCreteria varchar(4000)
DECLARE @SelectJoinPart varchar(max)
DECLARE @SelectOrderByPart varchar(255)
SET @SelectQueryWhere = ') _Results WHERE RowNumber > ' + Convert(varchar,@LastDisplayingRecordIndex) + ' And RowNumber <= ' + Convert(varchar,@MaxDisplayingRecordIndex)
SET @SelectOrderByPart='' -- Please mentioned If any
SET @QueryCount = 'SELECT count(UID) from userImage' -- It Used for Counting all the Records
SET @SelectMainQuery ='SELECT ImageID,UID,USERNAME,USERIMAGE,ROW_NUMBER()over (order by ImageID) AS RowNumber from userImage'
SET @SelectJoinPart =''-- There is any Joins Please put here
SET @SelectWhereCreteria = ' where UId = '+ Convert(varchar,@UID)--Here You Can put Your Calculated Where Creteria
SET @SelectMainQueryResultSet = @SelectMainQuery + @SelectJoinPart + @SelectWhereCreteria
SET @SelectMainQueryResultSet = 'SELECT * FROM ('+ @SelectMainQueryResultSet + @SelectQueryWhere + @SelectOrderByPart
SET @QueryCount = @QueryCount + @SelectJoinPart + @SelectWhereCreteria
EXEC(@SelectMainQueryResultSet)
--PRINT @SelectMainQueryResultSet
EXEC(@QueryCount)
--PRINT @QueryCount
END
*/
#endregion sp used for paging
}
using System.Data;
using System.Configuration;
using System.Collections;
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 BusenessLogic;
using BusenessObject;
public partial class MaheshPagingWithHelpofsanjeev : System.Web.UI.Page
{
BusenessObject.CustomPagingBo oCustomPaging = new CustomPagingBo();
int UserId = 1;
int PageSize = 1;
// static int TotalRows;
int GridCurrentPageIndex;
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["GridCurrentPageIndex"] != null && ViewState["GridCurrentPageIndex"].ToString() != "")
{
GridCurrentPageIndex = Convert.ToInt32(ViewState["GridCurrentPageIndex"]);
//LinkButton btnPrePage_Top = Page.FindControl("btnPrePage_Top") as LinkButton;
// btnPrePage_Top.Enabled = true;
}
else
{
GridCurrentPageIndex = 1;
// LinkButton btnPrePage_Top = Page.FindControl("btnPrePage_Top") as LinkButton;
// btnPrePage_Top.Enabled = false;
}
DisplayBottomPageLinks();
}
protected void DisplayBottomPageLinks()
{
if (ViewState["GridCurrentPageIndex"] != null && ViewState["GridCurrentPageIndex"].ToString() != "")
{
GridCurrentPageIndex = Convert.ToInt32(ViewState["GridCurrentPageIndex"]);
}
else
{
GridCurrentPageIndex = 1;
}
// Following code is used for the Gridview paging
Int32 count;
int showPages = 3;// 4; or 5 or 6 as you want (This is the key variable...)
//The variable showPages is used to show the no. of Pages you want to show at One time on the page..
LinkButton lnk;
Panel pnlPaging = Page.FindControl("pnlPaging") as Panel;
pnlPaging.Controls.Clear();
count = Convert.ToInt32(ViewState["count"]);
int pageSize = 1;
int totalPages = count / pageSize;
if (count % pageSize > 0)
{
totalPages += 1;
}
if (totalPages > 1)
{
for (int i = 0; i < totalPages; i++)
{
int pageNo = i + 1;
if (i != (GridCurrentPageIndex - 1))
{
if (i <= showPages)
{
if (i != showPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + pageNo.ToString();
lnk.Text = pageNo.ToString() + " ";
lnk.CausesValidation = false;
lnk.CommandArgument = pageNo.ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = pageNo.ToString();
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
if (i == showPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + pageNo.ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = pageNo.ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = pageNo.ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
if (GridCurrentPageIndex > showPages)
{
int x;
pnlPaging.Controls.Clear();
lnk = new LinkButton();
lnk.ID = "linkpage1";
lnk.Text = " << ";
lnk.CausesValidation = false;
lnk.CommandArgument = "1";
lnk.CommandName = "Paging_click";
lnk.ToolTip = "1";
//lnk.CssClass = "Paging";
lnk.Command += new CommandEventHandler(lnk_Command);
pnlPaging.Controls.Add(lnk);
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex - 1).ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex - 1).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex - 1).ToString();
lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
for (x = 0; x < showPages; x++)
{
if ((GridCurrentPageIndex + x) < totalPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex + x).ToString();
lnk.Text = (GridCurrentPageIndex + x).ToString() + " ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex + x).ToString();
lnk.CommandName = "Paging_click";
lnk.ToolTip = (GridCurrentPageIndex + x).ToString(); ;
lnk.Command += new CommandEventHandler(lnk_Command);
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
if (x == showPages && (GridCurrentPageIndex + x) <= totalPages)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex + x).ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex + x).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex + x).ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
if (i == (totalPages - 1) && (GridCurrentPageIndex != totalPages) && (totalPages > (showPages + 1)))
{
lnk = new LinkButton();
lnk.ID = "linkpage1" + totalPages.ToString();
lnk.Text = " >> ";
lnk.CausesValidation = false;
lnk.CommandArgument = totalPages.ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = totalPages.ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
if ((GridCurrentPageIndex == totalPages) && (totalPages > (showPages + 1)))
{
int x;
pnlPaging.Controls.Clear();
lnk = new LinkButton();
lnk.ID = "linkpage1";
lnk.Text = " << ";
lnk.CausesValidation = false;
lnk.CommandArgument = "1";
lnk.CommandName = "Paging_click";
lnk.ToolTip = "1";
lnk.Command += new CommandEventHandler(lnk_Command);
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex - showPages).ToString();
lnk.Text = " .. ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex - showPages).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex - showPages).ToString();
//lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
for (x = (showPages - 1); x > 0; x--)
{
lnk = new LinkButton();
lnk.ID = "linkpage" + (GridCurrentPageIndex - x).ToString();
lnk.Text = (GridCurrentPageIndex - x).ToString() + " ";
lnk.CausesValidation = false;
lnk.CommandArgument = (GridCurrentPageIndex - x).ToString();
lnk.CommandName = "Paging_click";
lnk.Command += new CommandEventHandler(lnk_Command);
lnk.ToolTip = (GridCurrentPageIndex - x).ToString();
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
}
else
{
if (i == (GridCurrentPageIndex - 1))
{
lnk = new LinkButton();
lnk.ID = "linkpage" + pageNo.ToString();
lnk.Text = pageNo.ToString() + " ";
lnk.CausesValidation = false;
lnk.ToolTip = pageNo.ToString();
//lnk.Attributes["OnClick"] = "return false;";
lnk.Enabled = false;
//lnk.ForeColor = System.Drawing.Color.Gray;
// lnk.CssClass = "Paging";
pnlPaging.Controls.Add(lnk);
}
}
}
}
}
protected void click_PreviousPage(object sender, EventArgs e)
{
GridCurrentPageIndex = GridCurrentPageIndex - 1;
Searching();
DisplayBottomPageLinks();
}
void lnk_Command(Object sender, CommandEventArgs e)
{
Panel pnlPaging = (Panel)Page.FindControl("pnlPaging");
ViewState["linkId"] = e.CommandArgument.ToString();
if (e.CommandName == "FirstPaging_click")
{
GridCurrentPageIndex = Convert.ToInt32(e.CommandArgument);
ViewState["GridCurrentPageIndex"] = GridCurrentPageIndex;
}
else if (e.CommandName == "Paging_click")
{
GridCurrentPageIndex = Convert.ToInt32(e.CommandArgument);
ViewState["GridCurrentPageIndex"] = GridCurrentPageIndex;
}
Searching();
LinkButton lnk = (LinkButton)pnlPaging.FindControl("linkpage" + ViewState["linkId"].ToString());
lnk.Enabled = false;
if (GridCurrentPageIndex == 1)
{
// LinkButton btnPrePage_Top = Page.FindControl("btnPrePage_Top") as LinkButton;
// btnPrePage_Top.Enabled = false;
}
}
protected void BtnShowUser_Click(object sender, EventArgs e)
{
Searching();
}
public void Searching()
{
ViewState["imgClick"] = "Image_Search";
oCustomPaging.Uid = UserId;
oCustomPaging.GridPageSize = PageSize;
oCustomPaging.GridCurrentPageIndex = GridCurrentPageIndex;
DisplayUser();
}
public void DisplayUser()
{
DataList1.DataSource = CustomPagingBl.GetImageData(oCustomPaging);
DataList1.DataBind();
ViewState["count"] = oCustomPaging.TotalRecords;
if (ViewState["GridCurrentPageIndex"] != null && ViewState["GridCurrentPageIndex"].ToString() != "")
{
GridCurrentPageIndex = Convert.ToInt32(ViewState["GridCurrentPageIndex"]);
}
else
{
GridCurrentPageIndex = 1;
}
DisplayBottomPageLinks();
}
#region sp used for paging
/*
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROC [dbo].[USP_DEMO_PAGING]
(
@UID INT,
@GridCurrentPageIndex INT,
@GridPageSize INT
)
AS
BEGIN
DECLARE @LastDisplayingRecordIndex int -- To store the index number of last displayed records in Grid in .NET page. For next page it will start by increment last index by 1.
DECLARE @MaxDisplayingRecordIndex int -- To store upto which index records should be display.
SET @LastDisplayingRecordIndex = @GridPageSize * (@GridCurrentPageIndex-1)
SET @MaxDisplayingRecordIndex = @GridPageSize * @GridCurrentPageIndex
-- VARIABLE DECLARATION FOR DYNAMIC QUERY PARTS TO BE USED IN PAGING
DECLARE @SelectQueryWhere varchar(500)-- Used to put the condtion of lower and higher record index
DECLARE @QueryCount varchar(max) -- Used to count the total records.
DECLARE @SelectMainQuery varchar(500) -- To store the selected column part of the SELECT statement
DECLARE @SelectMainQueryResultSet varchar(7000) -- To store the result set query with Row_Number
DECLARE @SelectWhereCreteria varchar(4000)
DECLARE @SelectJoinPart varchar(max)
DECLARE @SelectOrderByPart varchar(255)
SET @SelectQueryWhere = ') _Results WHERE RowNumber > ' + Convert(varchar,@LastDisplayingRecordIndex) + ' And RowNumber <= ' + Convert(varchar,@MaxDisplayingRecordIndex)
SET @SelectOrderByPart='' -- Please mentioned If any
SET @QueryCount = 'SELECT count(UID) from userImage' -- It Used for Counting all the Records
SET @SelectMainQuery ='SELECT ImageID,UID,USERNAME,USERIMAGE,ROW_NUMBER()over (order by ImageID) AS RowNumber from userImage'
SET @SelectJoinPart =''-- There is any Joins Please put here
SET @SelectWhereCreteria = ' where UId = '+ Convert(varchar,@UID)--Here You Can put Your Calculated Where Creteria
SET @SelectMainQueryResultSet = @SelectMainQuery + @SelectJoinPart + @SelectWhereCreteria
SET @SelectMainQueryResultSet = 'SELECT * FROM ('+ @SelectMainQueryResultSet + @SelectQueryWhere + @SelectOrderByPart
SET @QueryCount = @QueryCount + @SelectJoinPart + @SelectWhereCreteria
EXEC(@SelectMainQueryResultSet)
--PRINT @SelectMainQueryResultSet
EXEC(@QueryCount)
--PRINT @QueryCount
END
*/
#endregion sp used for paging
}
Show Medium size image when we mouse over on thumbnail image of GridView
Show Medium size image when we mouse over on thumbnail image of GridView
and show some description
[asp:ImageButton ID="imgBtnPropertyImage" runat="server" AlternateText="Dummy text"
CommandName="DetailsOnNextPage" Height="72" Width="92" onmouseover="ShowImageDiv(this,event)"
onmouseout="HideImageDiv()" /]
javaScript for show div.
[div id="divImgOnMouseOver" style="display: none; position: absolute; left: 610px;
top: 600px; height: 400px; width: 100px;"]
[table]
[tr]
[td class="normalblk" height="10px" bgcolor="#adcf42"]
[/td]
[/tr]
[tr]
[td bgcolor="#adcf42"]
[asp:Image ID="imgPropid" runat="server" ImageUrl="" Height="90" Width="130" /]
[/td]
[/tr]
[tr]
[td height="10px" class="normalblk" bgcolor="white"]
[asp:Label ID="lblPropDescriptiond" runat="server" Text="" /]
[/td]
[/tr]
[tr]
[td class="normalblk" bgcolor="#adcf42"]
[/td]
[/tr]
[/table]
[/div]
[script language="javascript" type="text/javascript"]
function ShowImageDiv(c,e)
{
var str = c.id;
str = str.replace(/imgBtnPropertyImage/,'description');
var div = document.getElementById('divImgOnMouseOver');
div.style.display='block';
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
div.style.left = e.clientX + 50 +'px';
div.style.top = ((e.clientY + scrollTop) - 100) +'px';//e.clientY +'px';
var image = document.getElementById('ctl00_ContentPlaceHolder1_imgPropid');
var lblDes = document.getElementById('ctl00_ContentPlaceHolder1_lblPropDescriptiond');
lblDes.innerHTML = document.getElementById(str).value;
var path = c.src;
image.src=path;
return false;
}
function HideImageDiv()
{
document.getElementById('divImgOnMouseOver').style.display='none';
}
[/script]
and show some description
[asp:ImageButton ID="imgBtnPropertyImage" runat="server" AlternateText="Dummy text"
CommandName="DetailsOnNextPage" Height="72" Width="92" onmouseover="ShowImageDiv(this,event)"
onmouseout="HideImageDiv()" /]
javaScript for show div.
[div id="divImgOnMouseOver" style="display: none; position: absolute; left: 610px;
top: 600px; height: 400px; width: 100px;"]
[table]
[tr]
[td class="normalblk" height="10px" bgcolor="#adcf42"]
[/td]
[/tr]
[tr]
[td bgcolor="#adcf42"]
[asp:Image ID="imgPropid" runat="server" ImageUrl="" Height="90" Width="130" /]
[/td]
[/tr]
[tr]
[td height="10px" class="normalblk" bgcolor="white"]
[asp:Label ID="lblPropDescriptiond" runat="server" Text="" /]
[/td]
[/tr]
[tr]
[td class="normalblk" bgcolor="#adcf42"]
[/td]
[/tr]
[/table]
[/div]
[script language="javascript" type="text/javascript"]
function ShowImageDiv(c,e)
{
var str = c.id;
str = str.replace(/imgBtnPropertyImage/,'description');
var div = document.getElementById('divImgOnMouseOver');
div.style.display='block';
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
div.style.left = e.clientX + 50 +'px';
div.style.top = ((e.clientY + scrollTop) - 100) +'px';//e.clientY +'px';
var image = document.getElementById('ctl00_ContentPlaceHolder1_imgPropid');
var lblDes = document.getElementById('ctl00_ContentPlaceHolder1_lblPropDescriptiond');
lblDes.innerHTML = document.getElementById(str).value;
var path = c.src;
image.src=path;
return false;
}
function HideImageDiv()
{
document.getElementById('divImgOnMouseOver').style.display='none';
}
[/script]
send mail through gmail sever
Hi,
This is code for send mail through gmail sever. with web config setting and namespaces
public static bool SendPwdInfo(string name, string pwd, string EmailTo)
{
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("info@helpondesk.com");
message.To.Add(EmailTo.Trim());
message.Subject = "Your Password!";
string MailFormat = "
";
message.Body = MailFormat;
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
//SmtpClient client = new SmtpClient();
//client.Host = "mail.a1technology.com";
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential mailAuth = new NetworkCredential("helpondesk@gmail.com", "abcdef");
client.EnableSsl = false;
client.UseDefaultCredentials = false;
client.Credentials = mailAuth;
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
client.Send(message);
return true;
}
catch
{
return false;
}
}
name space
//--------------------------------
using System.Net.Mail;
using System.Net;
Webconfig setting
Thanks
Helpondesk Team.
This is code for send mail through gmail sever. with web config setting and namespaces
public static bool SendPwdInfo(string name, string pwd, string EmailTo)
{
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("info@helpondesk.com");
message.To.Add(EmailTo.Trim());
message.Subject = "Your Password!";
string MailFormat = "
your login information is as follows - |
User name: "+name + ""; MailFormat += " |
Password: " + pwd + " |
message.Body = MailFormat;
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
//SmtpClient client = new SmtpClient();
//client.Host = "mail.a1technology.com";
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential mailAuth = new NetworkCredential("helpondesk@gmail.com", "abcdef");
client.EnableSsl = false;
client.UseDefaultCredentials = false;
client.Credentials = mailAuth;
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
client.Send(message);
return true;
}
catch
{
return false;
}
}
name space
//--------------------------------
using System.Net.Mail;
using System.Net;
Webconfig setting
Thanks
Helpondesk Team.
fill the drop down list and use Tinny window
Hi,
This code is for fill the drop down list .
1]
if (ds . Tables[0] . Rows . Count ] 0)
{
ddlSelectPage . DataSource = ds;
ddlSelectPage . DataTextField = "Page_Name";
ddlSelectPage . DataValueField = "Page_Title";
ddlSelectPage . DataBind();
ddlSelectPage . Items . Insert(0, new ListItem("-- Select Page --", "-1"));
}
set a value select from drop down
this . DropDownList1 . Items . FindByText("d") . Selected = true;
2]
Tinny Window will blocked by blocker.
function EnlargeImage()
{
var s = document . getElementById('ctl00_ContentPlaceHolder1_imgBox');
s= s . src;
myWindow = window . open("", "tinyWindow", 'toolbar,width=550,height=550,resizable=1,scrollbars=1')
myWindow . document . write("[html][head][title]Property Vertical[/title][/head][body ][table width=100%][tr][td
align=center valign=middle height=500 ][img src="+s+"][/td][/tr][/table][/body][/html]")
myWindow . document . close()
return false;
}
Thanks
helpondesk Team
This code is for fill the drop down list .
1]
if (ds . Tables[0] . Rows . Count ] 0)
{
ddlSelectPage . DataSource = ds;
ddlSelectPage . DataTextField = "Page_Name";
ddlSelectPage . DataValueField = "Page_Title";
ddlSelectPage . DataBind();
ddlSelectPage . Items . Insert(0, new ListItem("-- Select Page --", "-1"));
}
set a value select from drop down
this . DropDownList1 . Items . FindByText("d") . Selected = true;
2]
Tinny Window will blocked by blocker.
function EnlargeImage()
{
var s = document . getElementById('ctl00_ContentPlaceHolder1_imgBox');
s= s . src;
myWindow = window . open("", "tinyWindow", 'toolbar,width=550,height=550,resizable=1,scrollbars=1')
myWindow . document . write("[html][head][title]Property Vertical[/title][/head][body ][table width=100%][tr][td
align=center valign=middle height=500 ][img src="+s+"][/td][/tr][/table][/body][/html]")
myWindow . document . close()
return false;
}
Thanks
helpondesk Team
Subscribe to:
Posts (Atom)