Posts

Javascript code displayed in white color in visual studio 2017

Visual Studio Formatting Issues / Displayed JavaScript Code With Comment Its also known issue when copy text/code in visual studio showing "formatting selection" popup it will be also solved by below solution Solved: Goto in visual studio ( Options --> Text Editor --> JavaScript / TypeScript --> Language Service )

Error serializing - Exception of type System.Web.HttpUnhandledException was thrown.

Solved: You have to add [Serializable] attribute in the class and also add inherited class if you extend on that class. Why? Because you have created List or Dictionary type of property Inner Exception: System.ArgumentException: Error serializing value 'ModelClass' of type 'ModelClass.' ---> System.Runtime.Serialization.SerializationException: Type 'IMR.Model.Models.Admin.UserInOutLogSearch' in Assembly 'IMR.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.    at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)    at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()    at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingCon

how to stop pdf editing using itextsharp

Editable pdf file textbox, checkbox, etc. doesn't write after creating pdf file from itextsharp this file should not be editable code below: pdfStamper.FormFlattening =  true ;

Add Image through base64 on PDF in itextsharp

If you have base64 code image or image path, easily can add image in PDF from iTextSharp. Code below: PdfReader pdfReader =  new  PdfReader( "C:\\file.pdf" ); PdfStamper pdfStamper =  new  PdfStamper(pdfReader,  new  FileStream( "target save path" , FileMode.Create)); string  imagepath =  "base64 image code" ; Byte[] bytes = Convert.FromBase64String(Regex.Replace(imagepath, @ "^data:image\/[a-zA-Z]+;base64," ,  string .Empty)); var  pdfContentByte = pdfStamper.GetOverContent(1);  // page number iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(bytes); image1.SetAbsolutePosition(140, 70); image1.ScalePercent(20f); pdfContentByte.AddImage(image1); pdfStamper.Close();

How to find text in dropdownlist in asp.net

Finding item in dropdownlist from a string. ddlStudent.Items.Contains( new  ListItem("Dawood"))

Remove first and last special characters from string in c#

Sometimes we need to remove special character from staring and ending of a string. private   static   string  RemoveFirstAndLastSpecialCharacter( string  input) {      if  (input !=  string .Empty)     {          string  firstRemovableStr =  string .Empty;          string  lastRemovableStr =  string .Empty;          bool  IsLetter =  false ;          for  ( int  i = 0; i < input.Length; i++)         {              if  (! char .IsLetter(input[i]) && !IsLetter)                 IsLetter =  false ;              else                 IsLetter =  true ;              if  (IsLetter)                 firstRemovableStr = firstRemovableStr + input[i];         }         input = firstRemovableStr;         IsLetter =  false ;          for  ( int  k = 0; k < input.Length; k++)         {              if  (! char .IsLetter(input[(input.Length - k) - 1]) && !IsLetter)                 IsLetter =  false ;              else                 IsLetter =  true ;