Thursday, 12 February 2015

View Word Document using asp.net c#


In this article I will explain how to View Word Document using asp.net c#



String sFullPath = String.Empty;
string Physicalpath = System.IO.Path.Combine(Request.PhysicalApplicationPath, "Profile\\");
sFullPath = lblResumePath.Text;
string strFullpath = Physicalpath + sFullPath;
if (strFullpath != null && strFullpath.Length > 4)
{
  try
  {
    FileInfo _fileInfo = new FileInfo(strFullpath);
    if (_fileInfo.Exists)
    {
      object objMissing = System.Reflection.Missing.Value;
      Microsoft.Office.Interop.Word._Application objWord;
      Microsoft.Office.Interop.Word._Document objDoc;
      objWord = new Microsoft.Office.Interop.Word.Application();
      object fileName = @strFullpath;
      objDoc = objWord.Documents.Open(ref fileName,
      ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
      ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
      ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing);
    }
  }
  catch (Exception ex)
  {
               
  }
}
 

Thursday, 28 August 2014

Row number for grouped data in RDLC Report



Rownumber function returns the number of the row of the dataset

Student_Name
Raja
Durai
Raja Durai
Raja Durai
Raja Durai
S.R Durai

If we would like to groupby Student _Name and show the row number beside each row, the result will be :

Row number              Student _Name
1                                 Raja
2                                 Durai
3                                 Raja Durai
6                                 S.R Durai

As you can see the row number value is not correct, actually it is correct because the rownumber function returns the number of row inside the dataset not inside the grouped data in the report

I am going to use runningvalue function for the grouped data inside "table1"

=runningvalue(Fields!Student _Name.Value,countdistinct,"table1")

Result:

Rownumber              Student _Name
1                                 Raja
2                                 Durai
3                                 Raja Durai
4                                 S.R Durai

Thursday, 21 August 2014

Ajax ColorPicker in ASP.NET



       Now I’m going to explain how to use Ajax ColorPicker in ASP.NET. Ajax ColorPickerExtender provides client-side color-picking functionality with UI in a popup control.First you will add ajaxtoolkitcontrol.dll reference in your project. And give the below code in your aspx page.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="actk" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript">
        function Color_Changed(sender) {
            sender.get_element().value = "#" + sender.get_selectedColor();
        }
    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:TextBox ID="txtColor" runat="server" Width="150px" />
        <br />
        <div id="PreviewColor" style="width: 50px; height: 50px; border: 1px solid Gray">
        </div>
        <asp:Button ID="btnPicker" runat="server" Text="Choose Color" />
        <actk:ColorPickerExtender ID="ColorPicker1" runat="server" TargetControlID="txtColor"
            SampleControlID="PreviewColor" PopupButtonID="btnPicker" PopupPosition="Right"
            OnClientColorSelectionChanged="Color_Changed" />
    </div>
</asp:Content>

 Then run your project, The result will display same as given below.