Archive for May, 2008

keyword searching result from database in C#

Posted on May 23, 2008. Filed under: C# |

public static DataSet RelatedKeyword(string keyword)
{string[] arr =keyword.Replace(“& “,“”).Split(‘ ‘);
DataSet ds = new DataSet();
DataSet dsTemp = new DataSet();
bool flag = false;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["remote"].ConnectionString);
// DBAccess db = new DBAccess();
SqlDataAdapter sda;
foreach (string s in arr)
{ if (s.Length >= 2)
{ sda = new SqlDataAdapter(“select distinct top 60 keywordid, keywordname from keyword  where keywordname like ‘%’+@ksearch+’%’”, con);
sda.SelectCommand.Parameters.Add(“@ksearch”, SqlDbType.VarChar).Value = [...]

Read Full Post | Make a Comment ( None so far )

send data from html page to server pages

Posted on May 23, 2008. Filed under: JavaScript |

 

head>
<title>Untitled Page</title>
<script language=javascript>
function submitvalue()
{
var red=document.getElementById(‘rd’);
var val=“PH”;
if(rd[0].checked==true)
{val=“KH”;
}
window.location.href=“keywordsearch.aspx?kq=”+document.getElementById(‘txtsearch’).value+“&stype=”+val;
}
</script>
</head>
<body>
<input type=text name=”txtsearch” runat=server />
<input type=radio name=”rd” value=”KH” runat=server checked=checked/>
<input type=”radio” name=”rd” value=”PH” runat=server/>
<input type=”button” name=”btnsearch” value=”search” onclick=”submitvalue();”/>
</body>

Read Full Post | Make a Comment ( None so far )

Open .aspx page with parameter in popup window

Posted on May 16, 2008. Filed under: JavaScript |

<a href=”javascript:return false;” onclick=”javascript:window.open(’sendquery.aspx?rg=” + sd.REGID + “&comp=” + sd.COMPANYNAME + “&city=” + sd.CITYNAME + “‘,’smallwindowsms’,’toolbars=0,crollbars=0,width=600,
height=500,menubar=0,resizable=0′);return false;”>send query</a>

Read Full Post | Make a Comment ( None so far )

protect copy of data on page in javascript

Posted on May 15, 2008. Filed under: JavaScript |

<

SCRIPT language=javascript type=text/javascript> 
function disableCtrlKeyCombination(e)
{//list all CTRL + key combinations you want to disable 
var forbiddenKeys = new Array(‘a’, ‘n’, ‘c’, ‘x’, ‘v’, ‘j’);
var key;var isCtrl;
if(window.event)
{key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{for(i=0; i<forbiddenKeys.length; i++)
{// alert(forbiddenKeys[i]);
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{// [...]

Read Full Post | Make a Comment ( None so far )

Edit,Update and delete in datalist

Posted on May 15, 2008. Filed under: Asp.net |

<!– start html code –>
<asp:DataList ID=rp runat=server DataKeyField=”localityid” RepeatColumns=2 RepeatLayout=Table Width=400px OnCancelCommand=Cancel_Command OnEditCommand=edit OnUpdateCommand=update OnDeleteCommand=delete>
<ItemTemplate>
<asp:Label ID=lbl runat=server Text=’<%#Eval(”localityid” ;) %>’></asp:Label>
<asp:Label ID=lbl1 runat=server Text=’<%#Eval(”localityname” ;) %>’></asp:Label>
<asp:Button ID=edit Text=Edit CommandName=edit runat=server />
<asp:Button ID=delete Text=Delete CommandName=delete runat=server />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID=locid runat=server Text=’<%#Eval(”localityid” ;) %>’></asp:TextBox>
<asp:TextBox ID=locname runat=server Text=’<%#Eval(”localityname” ;) %>’></asp:TextBox>
<asp:Button ID=update Text=Update CommandName=update runat=server />
<asp:Button ID=”Cancle” Text=”Cancle” CommandName=”cancel” runat=server />
</EditItemTemplate>
 
</asp:DataList> 
<!–End html code –> 
<!–In codebehind [...]

Read Full Post | Make a Comment ( 3 so far )

using datediff function in sql

Posted on May 14, 2008. Filed under: Sql Server |

 select datediff(year,‘Nov 30 2001′,getdate()) as diffyear 
select datediff(month,‘Nov 30 2001′,getdate())as diffmonth
 select datediff(day,‘Nov 30 2001′,getdate()) as diffdaydiffyear
 diffyear
———–
 7 (1 row(s) affected)
diffmonth
———–
78(1 row(s) affected)
diffday
———-
2357(1 row(s) affected)

Read Full Post | Make a Comment ( None so far )

using datename function for name of month,day

Posted on May 14, 2008. Filed under: Sql Server |

 

select DATENAME(w, GETDATE()) AS ‘ Day Name’
day name
———
Wednesday
SELECT DATENAME(m, GETDATE()) AS ‘ month Name’
month name
———
may
 
 
 

Read Full Post | Make a Comment ( None so far )

Using Dateadd function adding day,month,year in date

Posted on May 14, 2008. Filed under: Sql Server |

select

dateadd(datepart,number,date)
eg-

select

DATEADD(month, 3, getdate()) 

Datepart

|Abbreviations
year| yy,yyyy 
quarter| qq,q 
month| mm,m 
dayofyear| dy,y 
day| dd,d 
week| wk,ww 
weekday| dw, w 
hour| hh
minute| mi,n 
second| ss, s

Read Full Post | Make a Comment ( None so far )

fixed header in Datagrid,Gridview in asp.net

Posted on May 13, 2008. Filed under: Asp.net |

<head runat=”server”>
<title>Untitled Page</title>
</head>
<script type=”text/javascript”>   
function showheader()
{
var ab= document.getElementById(”<%=gd.ClientID%>”);
var pnid = document.getElementById(”<%=pn.ClientID%>”);
var abc = ab.cloneNode(true);
var i = abc.rows.length -1;
for(;i>0;i– ;) abc.deleteRow(i)
ab.deleteRow(0)
pnid.appendChild(abc)
}
window.onload =showheader
</script>
<body>
<form id=”form1″ runat=”server”>
<div><asp:Panel ID=pn runat=server></asp:Panel>
<asp:Panel ID=pnn runat=server style=”overflow-y:scroll;height: 250px;weight:300px” >
<asp:GridView ID=”gd” runat=”server”>
</asp:GridView>
</asp:Panel>
</div>
</form>
</body>
code file//////////
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(”Server=.;Database=rubru;uid=sa;pwd=sa”);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = “select top 100 * from locality”;
cmd.Connection.Open();
SqlDataReader rdr = [...]

Read Full Post | Make a Comment ( 1 so far )

Sending mail in asp.net

Posted on May 12, 2008. Filed under: C# |

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.From=new MailAddress(”mymail@gmail.com”);
mail.To.Add(new MailAddress(”sendmail@yahoo.com”));//enter company name which send
mail.IsBodyHtml=true;
mail.Subject = “Sending Enquiry”;
mail.Body = “Enquiry About Company “;
//Proper Authentication Details need to be passed when sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential(”maymail@gmail.com”, “password”);
//Smtp Mail server of Gmail is “smpt.gmail.com” and it uses port no. 587
//For different server like yahoo this details changes and you [...]

Read Full Post | Make a Comment ( 1 so far )

« Previous Entries

    About

    Hi,I am Suresh Sharma(MCP) from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...