Monday, March 31, 2008

Simple mail sending code and mail body format with style sheet

we can put clsaa name in TDs becz we took the style.css path

public bool SendMailInvitation(string To, string Subject,string nameOfRecipient)
{

bool status = true;
string path = ApplicationPath.getApplicationPath();
try
{
string strMailStyle = "[link rel='stylesheet' type='text/css' href=" + path + "/css/style.css]";
String strMessage;

strMessage = "[table width='600px' border='0' align='center' cellpadding='0' cellspacing='0']";
strMessage += "[tr][td] [/td][/tr]";
strMessage += "[tr][td][table width='600px' border='0' cellspacing='2' cellpadding='4']";
strMessage += " [tr][td width='8'][/td]";
strMessage += "[td][/td]";
strMessage += "[td width='8'][/td][/tr]";
strMessage += " [tr][td][/td]";
strMessage += "[td][table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'][tr] [td

height='10px'][/td][/tr]";
strMessage += " [tr][td ] Hi " + nameOfRecipient + " :[/td] [/tr][tr] [td height='9px'][/td][/tr]";
strMessage += "[tr] [td height='6px'][/td][/tr]";
strMessage += " [tr][td ] Congratulations–you have been promoted to an Editor on *****.[/td] [/tr]";
strMessage += "[tr] [td height='6px'][/td][/tr]";
//
strMessage += " [tr][td ] When you sign in, you’re now able to create places and edit events on the site. [/td]

[/tr]";
strMessage += "[tr] [td height='6px'][/td][/tr]";
strMessage += " [tr][td ] Get started now by following the link below, or copy and paste it into your browser:

[/td] [/tr]";
strMessage += "[tr] [td height='6px'][/td][/tr]";

strMessage += "[tr][td ][a href='http://www.8**********.com']http://www.********l.com[/a][/td][/tr]";
strMessage += "[tr] [td height='6px'][/td][/tr]";

strMessage += " [tr][td ] Wield this immense power wisely.[/td] [/tr]";
strMessage += "[tr] [td height='6px'][/td][/tr]";




strMessage += "[tr] [td height='10px'][/td][/tr]";
strMessage += "[tr] [td ] -the *****Team [/td][/tr]";
strMessage += "[tr] [td height='1px' ] [/td][/tr]";
strMessage += " [tr][td ] **********.com, ****** 11201,[br/] USA –

www.********.com[/td][/tr]";
//Questions? Concerns? Acclaim? Contact us at feedback@**********.com
strMessage += " [tr][td ] Questions? Concerns? Acclaim? Contact us at [a

href='mailto:feedback@*****.com'] feedback@*******.com [/a] [/td][/tr]";

strMessage += "[/table][/td]";
strMessage += "[td][/td]";
strMessage += "[/tr][tr][td][/td]";
strMessage += " [td][/td]";
strMessage += "[td][/td]";
strMessage += "[/tr][/table][/td][/tr][/table]";

string message = strMessage + strMailStyle;
MailMessage Mail_Message = new MailMessage();
Mail_Message.From = new MailAddress("service@******.com");
Mail_Message.To.Add(new MailAddress(To));
Mail_Message.Subject = Subject; // "This is my subject";
Mail_Message.Body = message; // "This is the content";
Mail_Message.IsBodyHtml = true;
SmtpClient Smtp_Client = new SmtpClient();

Smtp_Client.Send(Mail_Message);

}
catch (Exception e)
{

status = false;
string str = e.Message;
}
return status;
}



This function retrive the server path where application is run and strugn string path

public static string getApplicationPath()
{
string Port = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
if (Port == null || Port == "80" || Port == "443")
Port = "";
else
Port = ":" + Port;
string Protocol = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_PORT_SECURE"];
if (Protocol == null || Protocol == "0")
Protocol = "http://";
else
Protocol = "https://";
string p = Protocol + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + Port +

System.Web.HttpContext.Current.Request.ApplicationPath;
p = p.Trim();
if (!p.EndsWith("/"))
p += "/";
return p;
}


2) set the folowing mail.net setting in web config

[system.net]
[mailSettings]
[smtp]
[network host="mail.*******.com" port="25" userName="mahesh.sharma@*********.com"

password="******"/]
[/smtp]
[/mailSettings]
[/system.net]
[/configuration]

http://errohandling.blogspot.com

http://errohandling.blogspot.com

Thsi Block of Code uses in following condition

When we Required to Redired on Error page whenever any unhandled error comes
and we need the technical specsification .
2) with the same place we can import namesapce for sending mail and send mail on same
sting.
this name space is must add
<%@ Import Namespace="System.Diagnostics" %>



void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err = string.Empty;
//Request.Url.ToString().Replace(".aspx","_ASPX");
err = objErr.Message.ToString().Replace(".aspx.cs", "ASPXCS").Replace(" ","b");// +"#" + objErr.StackTrace.ToString().Replace("\n", " ");
//EventLog.WriteEntry("Sample_WebApp", err, EventLogEntryType.Error);

HttpContext.Current.Session["err"];
// Response.Redirect("err.aspx?err="+err);
Server.ClearError();
}

Thursday, March 27, 2008

http://mcamks.blogspot.com/

http://mcamks.blogspot.com/

stored procdure for case senstive password

CREATE PROCEDURE [dbo].[CheckUserLogin] (
-- This sp is used for case senstive password
@username varchar(200),
@password varchar(200) )
AS
SELECT clientId FROM Userlogin WHERE username=@username AND CAST(password AS VARBINARY(999))= CAST(@password AS VARBINARY(999))

Wednesday, March 19, 2008

Remember on this site

Step 1) HttpCookie bCookie = new HttpCookie("Userdetails");
Step 2)
if (!IsPostBack) { #region --------------------------RememberME------------------------------------ // code for check remember me on site
if (Request.Cookies["Userdetails"] != null) { txtusername.Text = Server.HtmlEncode(Request.Cookies["Userdetails"].Values[0]).ToString(); txtpassword.Attributes.Add("value", Server.HtmlEncode(Request.Cookies["Userdetails"].Values[1])); chkRemmberMe.Checked = true;
} // End of code for check remember me on site #endregion --------------------------RememberME------------------------------------ }
Step 3)
Put this code when user successfull loged in
#region --------------------- RemMe-----------------------------
// set code of remember me if (chkRemmberMe.Checked == true) { // function for check that browser is cookkie enabled or not HttpCookie TestCookie = new HttpCookie("BrowserTest"); TestCookie.Values.Add("strname", "strValue"); Response.Cookies.Add(TestCookie); if (Server.HtmlEncode(Request.Cookies["BrowserTest"].Values[0]).ToString() != "strValue") { lblMsg.Text = "Browser is not cookie enabled"; chkRemmberMe.Checked = false; } else// if Browser is cookie enabled {
bCookie.Values["userName"] = txtusername.Text.Trim(); bCookie.Values["userPassword"] = txtpassword.Text.Trim(); bCookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(bCookie); lblMsg.Text = ""; } } else {
Response.Cookies["Userdetails"].Expires = DateTime.Now.AddYears(-30);
}
#endregion RemMe

Thanks
HELPONDESK TEAM

Friday, March 14, 2008

How open / show div on same place where mouse pointer Click

How open / show div on same place where mouse pointer clicks


[html]

[head]

[title]Test21[/title]

[style type="text/css"]

#sekrit {

display: none;

width: 100px;

height: 100px;

background-color: #dddddd;

border: 1px solid #000000;

position: absolute;

}

[/style]

[script type="text/javascript"]

function mouseOver(e) {

if (e == null) e = event;

var sekrit = document.getElementById('sekrit');

sekrit.style.display = 'block';

sekrit.style.left = e.clientX+'px';

sekrit.style.top = (e.clientY-sekrit.offsetHeight)+'px';

}

function mouseOut(e) {

// add stuff here

}

[/script]

[/head]

[body]

[br/][br/][br/][br/][br/][br/][br/]

[a href="#" onmouseover="mouseOver(event)" onmouseout="mouseOut(event);"]Test[/a]

[div id="sekrit"]Y HELO THAR![/div]

[/body]

[/html]

how show a div depends on condtions

step 1) create a update panel and fix div like as shown below


[
aja:UpdatePanel ID="UpdatePanelMailpeview" runat="server"]

[ContentTemplate]

[div style="position: absolute; display: none; background-color: #F3F3F3;" id="divEmailPreview"

runat="server"]

[table width="350" border="0" cellspacing="0" cellpadding="0"]

[tr]

[td style="width: 4px;"]

[img src="images/grey_box_big_tleft.gif" width="4" height="27" alt="" /]

[/td]

[td style="background-image: url(images/grey_box_big_tmiddle.gif); background-repeat: repeat-x;" class="heading_white1"]

Mail Preview

[/td]

[td style="width: 4px;"]

[img src="images/grey_box_big_tright.gif" width="4" height="27" alt="" /][/td]

[/tr]

[tr]

[td style="background-image: url(images/grey_box_big_mleft.gif); background-repeat: repeat-y;

width: 4px;"]

[/td]

[td]

[table width="94%" style="height: 187px;" border="0" align="center" cellpadding="0"

cellspacing="0"]

[tr]

[td valign="top"]

[table cellpadding="0" cellspacing="0" border="0" width="98%"]

[tr]

[td]

[asp:Literal ID="ltlMailPreview" runat="server"][/asp:Literal]

[/td]

[/tr]

[tr]

[td style="height: 10px;" align="center"]

[/td]

[/tr]

[tr]

[td align="center" valign="middle"]

[table]

[tr]

[td valign="middle"]

[asp:ImageButton ID="imgbtnSendmails" ImageUrl="~/images/send_btn1.gif" runat="server"

OnClick="imgbtnSendmails_Click" OnClientClick="return setPossitionUpdateProgress('200','400');"/]

[/td]

[td valign="middle"]

[asp:ImageButton ImageUrl="~/images/cancel_btn.gif" OnClientClick=" return DivMailClose();"

ID="ImageButton5" runat="server" /][/td]

[/tr]

[/table]

[/td]

[/tr]

[/table]

[/td]

[/tr]

[/table]

[/td]

[td style="background-image: url(images/grey_box_big_mright.gif); background-repeat: repeat-y;

width: 4px;"]

[/td]

[/tr]

[tr]

[td valign="top"]

[img src="images/grey_box_big_bleft.gif" width="4" height="4" alt="" /][/td]

[td valign="top" style="background-image: url(images/grey_box_big_bmiddle.gif); background-repeat: repeat-x;"]

[/td]

[td valign="top"]

[img src="images/grey_box_big_bright.gif" width="4" height="4" alt="" /][/td]

[/tr]

[/table]

[/div]

[/ContentTemplate]

[/aja:UpdatePanel]

step 2) now some woke with javaScript

[script language="javascript" type="text/javascript"]

function DivMailClose()

{

var a;

if(document.getElementById("[%=divEmailPreview.ClientID%]").style.display =='block')

{

document.getElementById("[%=divEmailPreview.ClientID%]").style.display='none';

document.getElementById("[%=divEmailPreview.ClientID%]").style.visibility='hidden';

}

a = HideMsgDivDetails2();

return a;

}

function DivShowMail()

{

var divEmailPreviewMain = document.getElementById("[%=divEmailPreview.ClientID%]");

divEmailPreviewMain.style.display='block';

divEmailPreviewMain.style.visibility='visible';

divEmailPreviewMain.style.position="absolute";

divEmailPreviewMain.style.top = '100px';

divEmailPreviewMain.style.left= '220px'

/* if (e == null) e = event;

divEmailPreviewMain.style.top = (e.clientY+15)+'px';

divEmailPreviewMain.style.left = (e.clientX+15)+'px';*/

return false;

}

[/script]

step 3) now come on code behind

if (true)

{

this.ltlMailPreview.Text = “Text which we wana show”;

fromAddressBook = true;

string strMailPreview = "";

System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanelMailpeview, this.GetType(), "mailPreview", strMailPreview, false);

}

Mahesh K. Sharma
Email me
mahesh.sharma@live.in

Step one Copy paste this code in html part.

make sure that css path will find.

css is as folows

.modalBackground

{

background-color:Gray;

filter:alpha(opacity=70);

opacity:0.7;

}

[asp:Label ID="lblMPE" runat="server" text=""][/asp:Label]

[asp:Panel ID="Panel1" runat="server" Style="display: none"]

[asp:Panel ID="Panel3" runat="server" CssClass="blue_light1" ]

[div style=" background-color: #f2f1f0;" id="divUnderAge13"

runat="server"]

[table width="350" border="0" cellspacing="0" cellpadding="0"]

[tr]

[td style="width: 4px;"]

[img src="images/grey_box_big_tleft.gif" width="4" height="27"

alt="" /]

[/td]

[td style="background-image: url(images/grey_box_big_tmiddle.gif);

background-repeat: repeat-x;" class="heading_white1"]

Account Registration

[/td]

[td style="width: 4px;"]

[img src="images/grey_box_big_tright.gif" width="4" height="27"

alt="" /][/td]

[/tr]

[tr]

[td style="background-image: url(images/grey_box_big_mleft.gif);

background-repeat: repeat-y;

width: 4px;"]

[/td]

[td]

[table width="94%" style="height: 55px;" border="0" align="center"

cellpadding="0"

cellspacing="0"]

[tr]

[td valign="top"]

[table cellpadding="0" cellspacing="0" border="0"

width="98%"]

[tr]

[td style="height:25px"]

[/td]

[/tr]

[tr]

[td ]

The Site is not intended for or directed

to persons under the age of 13.

Because, if you register for an account

with us, you represent to us.

that's why you are 13 years of age or

older. (Dummy Text)*

[/td]

[/tr]

[tr]

[td style="height:15px"]

[/td]

[/tr]

[tr][td align="center"]

[asp:ImageButton ID="OkButton" runat="server"

ImageUrl="~/images/ok_btn.gif" AlternateText="Okay" OnClick="OkButton_Click" /]

[/td][/tr]

[tr]

[td style="height:15px"]

[/td]

[/tr]

[/table]

[/td]

[/tr]

[/table]

[/td]

[td style="background-image: url(images/grey_box_big_mright.gif);

background-repeat: repeat-y;

width: 4px;"]

[/td]

[/tr]

[tr]

[td valign="top"]

[img src="images/grey_box_big_bleft.gif" width="4" height="4"

alt="" /][/td]

[td valign="top" style="background-image:

url(images/grey_box_big_bmiddle.gif); background-repeat: repeat-x;"]

[/td]

[td valign="top"]

[img src="images/grey_box_big_bright.gif" width="4" height="4"

alt="" /][/td]

[/tr]

[/table]

[/div]

[p style="text-align: center;"]

[/p]

[/asp:Panel]

[/asp:Panel]

[ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"

TargetControlID="lblMPE"

PopupControlID="Panel1"

BackgroundCssClass="modalBackground"

OnOkScript="onOk()"

DropShadow="false"

Drag="false"

PopupDragHandleControlID="Panel3"

/]

Step 2) now on code behind

if (true)

{

ModalPopupExtender1.Show();

}

else

{

}

Mahesh K. Sharma.

E-mail me

mahesh.sharma@live.in

How we can open Ajax modal window depends on condition

Step one Copy paste this code in html part.

make sure that css path will find.
css is as folows
.modalBackground
{
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}






















Account Registration




























The Site is not intended for or directed to persons under the age of 13.
Because, if you register for an account with us, you represent to us.
that's why you are 13 years of age or older. (Dummy Text)*





























Step 2) now on code behind

if (true)
{
ModalPopupExtender1.Show();
}
else
{

}

here one thing more if u wana always call modal window the set lable id of its

Behaviour id .

Mahesh K. Sharma.
E-mail me
mahesh.sharma@live.in