.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

URL Encription and decription in ASP.NET..

Posted By:Athira Sreejith       Posted Date: December 31, 2008    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  
 

URL Encription and decription in ASP.NET..

While passing values as querystring and redirecting to another page,that time we can use this way ..


VetcareEncoding.aspx:

private void SendMail()
{
try
{
MailMessage m_newmail = new MailMessage();
SmtpClient s_client = new SmtpClient();
string attachfile=string.Empty;
Attachment m_attach;
string attachfile1=string.Empty;
string strdir = string.Empty;
MailAddress fromAdr = new MailAddress(txtEmail.Text);
m_newmail.From = fromAdr;

string strMailId = System.Configuration.ConfigurationManager.AppSettings["MailId"].ToString();
m_newmail.To.Add(strMailId);
m_newmail.Subject = "About Enquiry";

StringBuilder MailBody = new StringBuilder();
MailBody.Append("Name :" + txtName.Text.Trim() + "
");
MailBody.Append("Designation :" + txtDesgntn.Text + "
");
MailBody.Append("Company Name :" + txtCoName.Text + "
");
MailBody.Append("Address :" + txtAddress.Text + "
");
MailBody.Append("Pin :" + txtPin.Text + "
");
MailBody.Append("Country :" + txtCountry.Text + "
");
MailBody.Append("Telephone :" + txtTel1.Text + "-" + txtTel2.Text + "-" + txtTel3.Text + "
");
MailBody.Append("Fax :" + txtFax.Text + "
");
MailBody.Append("Like to comment on :" + cmbComment.SelectedValue + "
");
MailBody.Append("Suggestions :" + txtSuggestions.Text + "
");
MailBody.Append("Please tell us what you are looking for in enquiry :" + chklstEnquiry.SelectedValue + "
");
MailBody.Append("Additional Information :" + txtAdditionalInfo.Text + "
");
MailBody.Append("How did you here about us :" + cmbSelect.SelectedValue + " 
");

m_newmail.Body = MailBody.ToString();
m_newmail.IsBodyHtml = true;

if(fileName.HasFile)
{
attachfile = Path.GetFileName(fileName.PostedFile.FileName);
fileName.PostedFile.SaveAs(Server.MapPath(attachfile));

m_attach = new Attachment(Server.MapPath(attachfile));

m_newmail.Attachments.Add(m_attach);
attachfile1 = attachfile;
}
s_client.Host = "localhost";
s_client.UseDefaultCredentials = true;
s_client.Send(m_newmail);

ClientScript.RegisterClientScriptBlock(this.GetType(), "Hi!", String.Format("alert('An email has successfully been sent to {0}');", m_newmail.To), true);
ClearAll();

m_newmail.Dispose();

if (attachfile1 != null)
{
File.Delete(Server.MapPath(attachfile1));
}
}
catch (Exception ex)
{
ClearAll();
}
}



.CS Page:

string URL = VetCareEncription.encryptQueryString("Previous");
Response.Redirect("Performanceappraisal2.aspx?IsAction=" + URL);
 

     

Further Readings:

    Responses

    No response found. Be the first to respond this post

    Post Comment

    You must Sign In To post reply
    Find More code samples in C#, ASP.Net, Vb.Net and more Here

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend