Archive for the ‘ASP.Net’ Category
  • String bday = "06/20/2010"; DateTime ukDateFormat = DateTime.Parse(bday, System.Globalization.CultureInfo.GetCultureInfo("en-us")); Response.Write(ukDateFormat);... more »
  • I was working on a project and have been asked to convert the webpage into a pdf document. I have found a solution in a forum, but it was in c#, I have converted it in VB.net. See below method to convert a webpage into a PDF document. First, you need to download iTextSharp. iTextSharp is a port of the iText open source java library  which allows you to generate PDF files on the fly. Once you downloaded the library, you need to reference it in your project. To reference the downloaded the ... more »
  • If you are writing a program to send a mail with an attachment, then you might come across the problem with some random ATTXXXXX.dat file.if you you don't attach a file with the email, then by default ASP.NET will send a weird random ATTxxxxxxx.dat file. To bypass this, put a validation in the file attachment.If Not String.IsNullOrEmpty(AttachmentFileFiled.FileName) Then put the attachment code here ' e.g mm.Attachments.Add(New Attachment(AttachmentFileField.PostedFile.InputStream, Attac... more »
  • I found a nice article about how to send emails using System.Net.Mail on asp.net forums. Have a look at asp.net forum... more »
  • I found a nice article about how to send emails using System.Net.Mail on asp.net forums. Click the following link to access the page asp.net forum... more »
  • This code should be in yourfilename.aspx.vb . Const maxFileSize As Integer = 1048576 Dim intDocFileLength As Integer = Me.AttachmentFile.PostedFile.ContentLength If intDocFileLength > maxFileSize Then Label1.Text = "File size exceeds the limit of 1MB." Exit Sub End If *AttachmentFile is the name of the fileupload control ID.... more »
  • If you want to filter the filetype in a fileupload control: < asp:FileUpload ID="AttachmentFile" runat="server" Width="240px" style="background-color: #FFF0E1" /> < asp:RegularExpressionValidator id="FileUpLoadValidator" runat="server" ErrorMessage="Th file type is not allowed." ValidationExpression="^.+(.doc|.DOC|.pdf|.PDF)$" ControlToValidate="AttachmentFile" style="font-size: x-small" > This will only allow to upload doc and pdf file types. You could use other methods to ... more »
  • If you want to limit the number of characters in a text field use the code below: < asp:TextBox runat="server" ID="Body" TextMode="MultiLine" MaxLength="5" Columns="55" Rows="10" BackColor="#FFCC99" Width="346px" style="background-color: #FFF0E1"> < asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="Body" Display="Dynamic" ErrorMessage="25 char... more »
  • How to use the 'RegularExpressionValidator' and 'RequiredFieldValidator' in ASP.NET: I have used these to validate an email address. see the code below: < asp:TextBox runat="server" ID="Email" Columns="30"> < asp:RequiredFieldValidator ID="EmailValidator" runat="server" ControlToValidate="Email" display="Dynamic" ErrorMessage="Email must be filled out" /> < asp:RegularExpressionValidator ID="EmailValidator2" runat="server" ControlToValidate="ToEmail" Display="Dynamic" ... more »
  • * I have used VB in this demonstration. If you want to handle the error for the whole application in ASP.NET, you could use the global.asax. Put the below code in global.asax under Application_Error(). Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when an unhandled error occurs Dim currentException As Exception currentException = Server.GetLastError.GetBaseException() Response.Redirect("/error.aspx?Err=" & Server.UrlEn... more »
My Networks

Follow me in these Social Networks

Categories
Photos
DSC02754 Wales DSC02721 DSC02762 DSC02742 DSC02776 DSC02695 DSC02779 DSC02810
sanjeeve
Archives