string username=""; //username string
string useremaipart=""; //email string
// for selecting username's
-->select username from table1 where username like'%" + username+ "%'
// for selecting emailid's
-->select username from table1 where SUBSTRING(email,1,CHARINDEX('@',email)-1) like'%" + useremaipart+ "%'
Wednesday, June 24, 2009
Tuesday, June 23, 2009
New window settings using javascript
popupwindow option in asp.net(Code behind)
===================================
string URL ="asppage.aspx";
Response.Write("<script language=javascript>window.open('" + URL + "',null,'left=100, top=100,width=657,height=500,status=no, resizable= no, scrollbars= yes, toolbar= no,location= no, menubar= no,titlebar=0')</script>");
Close window option in asp.net(Code behind)
===================================
Response.Write("<script language='javascript'> { window.close();}</script>");
===================================
string URL ="asppage.aspx";
Response.Write("<script language=javascript>window.open('" + URL + "',null,'left=100, top=100,width=657,height=500,status=no, resizable= no, scrollbars= yes, toolbar= no,location= no, menubar= no,titlebar=0')</script>");
Close window option in asp.net(Code behind)
===================================
Response.Write("<script language='javascript'> { window.close();}</script>");
Thursday, June 4, 2009
Take a Value from webconfig
/* In webconfig file add the following code...
<appsettings>
<add key="ChooseMode" value="LIVE"></add><!--
Set ChooseMode as TEST for test server.
Set ChooseMode as LIVE for live server.
-->
</appsettings>
/* We can take this value by using c#,asp.net 2.0 by giving the key "ChooseMode" is
using System.Configuration; //name space
string ChooseMode=System.Configuration.ConfigurationManager.AppSettings
.Get("ChooseMode");
<appsettings>
<add key="ChooseMode" value="LIVE"></add><!--
Set ChooseMode as TEST for test server.
Set ChooseMode as LIVE for live server.
-->
</appsettings>
/* We can take this value by using c#,asp.net 2.0 by giving the key "ChooseMode" is
using System.Configuration; //name space
string ChooseMode=System.Configuration.ConfigurationManager.AppSettings
.Get("ChooseMode");
Wednesday, June 3, 2009
SQL--Convert (binary) in to string using sql
/* datafield--->binary(imageformat) field in table (or blob field in mysql)*/
/* in ms sql give the following code...*/
Convert(char,Convert(binary,datafield)))
/* in my sql give the following code...*/
cast(datafield as char)
/* in ms sql give the following code...*/
Convert(char,Convert(binary,datafield)))
/* in my sql give the following code...*/
cast(datafield as char)
Allow numbers (0-9), and periods (.) for Registration form(Asp.net+C#)
string password=string.empty /* (Give ur password here) */
if (!Regex.IsMatch( password, "^[-0-9a-zA-Z_.]{3,25}$"))
{
Response.Write("Sorry, only letters (a-z), numbers (0-9), and periods (.) are allowed for
password.");
}
if (!Regex.IsMatch( password, "^[-0-9a-zA-Z_.]{3,25}$"))
{
Response.Write("Sorry, only letters (a-z), numbers (0-9), and periods (.) are allowed for
password.");
}
Mail sending from C#.Net (.NEt2.0,Godaddy hosting)
Namespace used :
using System.Net.Mail;
using System.Net;
Code in C#.Net :
public void sendMail()
{
MailMessage objMail = new MailMessage();
objMail.To.Add(new MailAddress("toaddress"));
objMail.From = new MailAddress("fromaddress", "dispalyname");
objMail.Subject = "mailSubject";
objMail.CC.Add("Ccmailaddress");
objMail.Bcc.Add("Bccmailaddress");
objMail.IsBodyHtml = true;
objMail.Priority=MailPriority.High;
objMail.Body = "mailContent";
SmtpClient objSmtp = new SmtpClient("relay-hosting.secureserver.net");
objSmtp.Credentials=CredentialCache.DefaultNetworkCredentials;
objSmtp.DeliveryMethod=SmtpDeliveryMethod.Network;
objSmtp.Send(objMail);
}
using System.Net.Mail;
using System.Net;
Code in C#.Net :
public void sendMail()
{
MailMessage objMail = new MailMessage();
objMail.To.Add(new MailAddress("toaddress"));
objMail.From = new MailAddress("fromaddress", "dispalyname");
objMail.Subject = "mailSubject";
objMail.CC.Add("Ccmailaddress");
objMail.Bcc.Add("Bccmailaddress");
objMail.IsBodyHtml = true;
objMail.Priority=MailPriority.High;
objMail.Body = "mailContent";
SmtpClient objSmtp = new SmtpClient("relay-hosting.secureserver.net");
objSmtp.Credentials=CredentialCache.DefaultNetworkCredentials;
objSmtp.DeliveryMethod=SmtpDeliveryMethod.Network;
objSmtp.Send(objMail);
}
Equating text datatype with string in SQL
/* datafield-->field in tabl(text datatype)
variable-->string field */
convert(char,datafield)=convert(char, 'variable')
variable-->string field */
convert(char,datafield)=convert(char, 'variable')
Set Paging in Datagrid
/*set Allow paging=true (in datagrid properties) and write the following code.. */
protected void DataGrid1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
DataGrid1.PageIndex = e.NewPageIndex;
LoadDataGrid1();
}
protected void DataGrid1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
DataGrid1.PageIndex = e.NewPageIndex;
LoadDataGrid1();
}
check
Date format MS SQL
To format date as yyyy-mm-dd in MS SQL :select convert(char(10),getdate(),121);
Result format : 2009-06-03
select convert(char(19),getdate(),121);
Result format : 2009-06-03 15:55:00
Subscribe to:
Posts (Atom)