pnl.Style["display"] = "block";
Tuesday, July 1, 2014
Sunday, June 29, 2014
get checkbox checked in gridview in asp.net
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
if (chkRow.Checked)
{
string name = row.Cells[1].Text;
}
}
}
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox);
if (chkRow.Checked)
{
string name = row.Cells[1].Text;
}
}
}
convert datetime format to date only in asp.net
string sessionscheduleid, sessionname, sessionid, duration, startdate, enddate;
DateTime fromdate, todate;
fromdate = Convert.ToDateTime(hdffromdate.Value);
todate = Convert.ToDateTime(hdftodate.Value);
startdate = fromdate.ToShortDateString();
enddate = todate.ToShortDateString();
DateTime fromdate, todate;
fromdate = Convert.ToDateTime(hdffromdate.Value);
todate = Convert.ToDateTime(hdftodate.Value);
startdate = fromdate.ToShortDateString();
enddate = todate.ToShortDateString();
send multiple parameters to javascript in asp.net
<a href="#" onclick="BindSessionId('<%#Eval("ID") %>','<%#Eval("SessionName") %>','<%#Eval("fromDate") %>','<%#Eval("toDate") %>','<%#Eval("SessionID") %>');"
data-reveal-id="myModal" data-animation="fade">Invite </a>
function BindSessionId(sessionscheduleid, sessioname, fromdate, todate, sessionid) {
alert(sessionid);
$('input[id$=hdfsessionid]').val(sessionid);
$('input[id$=hdfsessionscheduleid]').val(sessionscheduleid);
$('input[id$=hdfsessionname]').val(sessioname);
$('input[id$=hdffromdate]').val(fromdate);
$('input[id$=hdftodate]').val(todate);
}
data-reveal-id="myModal" data-animation="fade">Invite </a>
function BindSessionId(sessionscheduleid, sessioname, fromdate, todate, sessionid) {
alert(sessionid);
$('input[id$=hdfsessionid]').val(sessionid);
$('input[id$=hdfsessionscheduleid]').val(sessionscheduleid);
$('input[id$=hdfsessionname]').val(sessioname);
$('input[id$=hdffromdate]').val(fromdate);
$('input[id$=hdftodate]').val(todate);
}
send mail in asp.net with attachment and images
MailMessage m = new MailMessage();
SmtpClient sc = new SmtpClient();
try
{
m.From = new MailAddress("from@gmail.com", "Shekhar");
m.To.Add(new MailAddress("snawale@curologic.com", "Amit"));
// m.CC.Add(new MailAddress("CC@yahoo.com", "Display name CC"));
//similarly BCC
m.Subject = " This is a Test Mail";
m.IsBodyHtml = true;
m.Body = "Phone number - 9822647640";
/* // Send With Attachements.
FileStream fs = new FileStream("E:\\TestFolder\\test.pdf",
FileMode.Open, FileAccess.Read);
Attachment a = new Attachment(fs, "test.pdf",
MediaTypeNames.Application.Octet);
m.Attachments.Add(a);
*/
/* // Send html email wiht images in it.
string str = "<html><body><h1>Picture</h1><br/><img
src=\"cid:image1\"></body></html>";
AlternateView av =
AlternateView.CreateAlternateViewFromString(str,
null,MediaTypeNames.Text.Html);
LinkedResource lr = new LinkedResource("E:\\Photos\\hello.jpg",
MediaTypeNames.Image.Jpeg);
lr.ContentId = "image1";
av.LinkedResources.Add(lr);
m.AlternateViews.Add(av);
*/
sc.Host = "smtp.gmail.com";
sc.Port = 587;
sc.Credentials = new
System.Net.NetworkCredential("from@gmail.com", "password");
sc.EnableSsl = true;
sc.Send(m);
Response.Write("Email Send sucessfully");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
SmtpClient sc = new SmtpClient();
try
{
m.From = new MailAddress("from@gmail.com", "Shekhar");
m.To.Add(new MailAddress("snawale@curologic.com", "Amit"));
// m.CC.Add(new MailAddress("CC@yahoo.com", "Display name CC"));
//similarly BCC
m.Subject = " This is a Test Mail";
m.IsBodyHtml = true;
m.Body = "Phone number - 9822647640";
/* // Send With Attachements.
FileStream fs = new FileStream("E:\\TestFolder\\test.pdf",
FileMode.Open, FileAccess.Read);
Attachment a = new Attachment(fs, "test.pdf",
MediaTypeNames.Application.Octet);
m.Attachments.Add(a);
*/
/* // Send html email wiht images in it.
string str = "<html><body><h1>Picture</h1><br/><img
src=\"cid:image1\"></body></html>";
AlternateView av =
AlternateView.CreateAlternateViewFromString(str,
null,MediaTypeNames.Text.Html);
LinkedResource lr = new LinkedResource("E:\\Photos\\hello.jpg",
MediaTypeNames.Image.Jpeg);
lr.ContentId = "image1";
av.LinkedResources.Add(lr);
m.AlternateViews.Add(av);
*/
sc.Host = "smtp.gmail.com";
sc.Port = 587;
sc.Credentials = new
System.Net.NetworkCredential("from@gmail.com", "password");
sc.EnableSsl = true;
sc.Send(m);
Response.Write("Email Send sucessfully");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
code for Send mail in asp.net
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("from@gmail.com");
mail.To.Add("send@curologic.com");
//mail.To.Add("toaddress2@gmail.com");
mail.Subject = "Password Recovery ";
mail.Body += " <html>";
mail.Body += "<body>";
mail.Body += "<table>";
mail.Body += "<tr>";
mail.Body += "<td>User Name : </td><td> HAi </td>";
mail.Body += "</tr>";
mail.Body += "<tr>";
mail.Body += "<td>Password : </td><td>aaaaaaaaaa</td>";
mail.Body += "</tr>";
mail.Body += "</table>";
mail.Body += "</body>";
mail.Body += "</html>";
mail.IsBodyHtml = true;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("from@gmail.com", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("from@gmail.com");
mail.To.Add("send@curologic.com");
//mail.To.Add("toaddress2@gmail.com");
mail.Subject = "Password Recovery ";
mail.Body += " <html>";
mail.Body += "<body>";
mail.Body += "<table>";
mail.Body += "<tr>";
mail.Body += "<td>User Name : </td><td> HAi </td>";
mail.Body += "</tr>";
mail.Body += "<tr>";
mail.Body += "<td>Password : </td><td>aaaaaaaaaa</td>";
mail.Body += "</tr>";
mail.Body += "</table>";
mail.Body += "</body>";
mail.Body += "</html>";
mail.IsBodyHtml = true;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("from@gmail.com", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
Friday, June 27, 2014
How to Get Window NT Logged User Name Using ASP.NET
1) System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
string strName = p.Identity.Name;
2)
string strName = HttpContext.Current.User.Identity.Name.ToString();3) string strName = Request.ServerVariables["AUTH_USER"]; //Finding with name
string strName = Request.ServerVariables[5]; //Finding with index
Subscribe to:
Posts (Atom)