LINQ to SQL :- Importent Method OnValidate

LINQ to SQL :- Importent Method OnValidate

OnValidate is good method in linq to sql technology.


This Method allow to Do validation or set default entry which you want to do before Insert,Update or Delete.

Example of Such uses are :-

1.) Set Default Value While performing DML operation.

2.) If you want to Check Duplication Inserting then u can perform it here.

3.) While keeping autodelte,autoinserting,autoupdating u can perform any operation which required before insert,update or delete.

Posted in | 0 comments

Convert HTML to Word Document using ASP.Net (C#)

Hello Frd's

Find Below code to Convert HTML to Word Document using ASP.Net (C#).

 HttpContext.Current.Response.Clear();  
     HttpContext.Current.Response.Charset = "";  
     HttpContext.Current.Response.ContentType = "application/msword";  
     string strFileName = "GenerateDocumentfgfgfg" + ".doc";  
     HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);  
     StringBuilder strHTMLContent = new StringBuilder();  
     strHTMLContent.Append(RadEditor1.Content); 
     -- RadEditor1.Content is HTML Text  I m taking it from editor.
 
     HttpContext.Current.Response.Write(strHTMLContent);  
     HttpContext.Current.Response.End();  
     HttpContext.Current.Response.Flush();  


If you have any question write in comment box.


Enjoy !!!!!

Posted in | 15 comments

Convert Word Document to HTML using ASP.Net (C#)

Hello Frd's

Find Below Code to Convert Word Document to HTML using ASP.Net (C#).

  

Variable Declaration :-


     protected Microsoft.Office.Interop.Word.ApplicationClass objWord = new      
                                                         ApplicationClass();    
    protected string strPathToUpload; //Path to upload files "Uploaded"
    protected string strPathToConvert; //Path to convert uploaded files and save
    object fltDocFormat = 10; //For filtered HTML Output
    protected object missing = System.Reflection.Missing.Value;
    protected object readOnly = false; //Open file in readOnly mode
    protected object isVisible = false;//The process has to be in invisible mode


Actual Method :-


try  
     {  
       //To check the file extension if it is word document or something else  
       string strFileName = fUpload.FileName;  
       string[] strSep = fUpload.FileName.Split('.');  
       int arrLength = strSep.Length - 1;  
       string strExt = strSep[arrLength].ToString().ToUpper();  
       //Save the uploaded file to the folder  
       strPathToUpload = Server.MapPath("Upload");  
       //Map-path to the folder where html to be saved  
       strPathToConvert = Server.MapPath("Upload");  
       object FileName = strPathToUpload + "\\" + fUpload.FileName;  
       object FileToSave = strPathToConvert + "\\" + fUpload.FileName + ".htm";  
       if (strExt.ToUpper().Equals("DOC"))  
       {  
         fUpload.SaveAs(strPathToUpload + "\\" + fUpload.FileName);  
         lblMessage.Text = "File uploaded successfully";  
         //open the file internally in word. In the method all the parameters should be passed by object reference  
         objWord.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing, ref missing);  
         //Do the background activity  
         objWord.Visible = false;  
         Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;  
         oDoc.SaveAs(ref FileToSave, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);  
         lblMessage.Text = fUpload.FileName + " converted to HTML successfully";  
       }  
       else  
       {  
         lblMessage.Text = "Invalid file selected!";  
       }  
       //Close/quit word  
       objWord.Quit(ref missing, ref missing, ref missing);  
     }  
     catch (Exception ex)  
     {  
       Response.Write(ex.Message);  
     }  


If you have any question post in comment.

Enjoy !!!!!

Posted in | 1 comments