Saturday, 31 December 2011

Email Sending in

using System.Net;
using System.Net.Mail;

private string MailFrom = "";
private string MailPassword = "myPassword";
public string MailSubject { get; set; }
public string MailTo { get ; set;}
public string MailBody { get; set; }
public string Attachment { get; set; }

public void SendEmail()

            SmtpClient smtp = new SmtpClient("", 587);
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new NetworkCredential(MailFrom, MailPassword);
            MailMessage msg = new MailMessage(MailFrom, MailTo);         
            Attachment att = new Attachment (Attachment);
            msg.Subject = MailSubject;
            msg.Body = MailBody;          
            msg.IsBodyHtml = true;
            smtp.EnableSsl = true;

Thursday, 29 December 2011

Alert Messages for Ajaxed pages

We can use the following code for alert messages in ajaxed pages:

ScriptManager.RegisterStartupScript(this, this.GetType(), "msg", "alert(' Message....? ');", true);

Dynamic Calendar Extender in Ajax Control Toolkit

Here we are going to create a textbox and Ajax Calendar Extender dynamically.

TextBox textbox = new TextBox();
textbox.ID = this.ID + "Textbox";
textbox.Text = this.EditableField.TextValue;
textbox.TextChanged += new EventHandler(HandleTextboxTextChanged);
textbox.Width = new Unit(100, UnitType.Pixel);
CalendarExtender calExender = new CalendarExtender();
calExender.PopupButtonID = "Image1";
calExender.TargetControlID = textbox.ID;

The form should contain toolkit script manager.

Tuesday, 8 November 2011

Preventing the use of backbutton in

We can use the javascript code below  to prevent the use of backbutton in webpages.

<script type="text/javascript">
function noBack(){window.history.forward();}