How to send mail with attachment through coding?

MailMessage obj = new MailMessage(); obj.From = new MailAddress(“admin@asd.com”); obj.To.Add(“gaur1982@yahoo.com”); obj.Subject = “Only 4 testing”; obj.IsBodyHtml = true; obj.Body = message.ToString(); Attachment atch=new Attachment(Server.MapPath(“~/Attach/123.txt”)); obj.Attachment.Add(atch); SmtpClient client = new SmtpClient(“127.0.0.1”, 25); client.Send(obj);

How do you turn off cookies for one page in your site?

You can’t turn off cookies in a single page but if you want to turn off the cookies in an application <sessionState cookieless = “true” /> in web.config file. Turn off Cookie in your browser – Mozilla FireFox Tools-Options-deselect cookie, if selected. — OR — Use the Cookie.Discard Property which… Continue reading

Which method do you use to redirect the user to another page without performing a round trip to the client?

Server.Transfer(): Client is shown as it is on the requesting page only, but the all the content is of the requested page. Data can be persist accros the pages using Context. Item collection, which is one of the best way to transfer data from one page to another keeping the… Continue reading

How to use CustomValidator in aspx page?

The CustomValidator control allows you to write a method to handle the validation of the value entered in aspx page and you can use this in this way: <asp:CustomValidator ID=”CustomValidator1″ runat=”server” ErrorMessage=”Sms length is exceeding over 160.” ClientValidationFunction=”validateLength” ControlToValidate=”txtSmsMessage” SetFocusOnError=”True” ValidationGroup=”add”>*</asp:CustomValidator> <script language=”javascript” type=”text/javascript”> function validateLength(oSrc, args) { args.IsValid =… Continue reading