Monday, December 29, 2014

telerik RadEditor Remove unwanted tool buttons from Radeditor

We can remove unwanter buttons from telerik RadEditor using following code. We just need to specify all the buttons which we need in an editor and their order.


<telerik:RadEditor runat="server" ID="EditorImageUrl">
  <ImageManager ViewPaths="~/G/L,~/G/C" UploadPaths="~/G/L" DeletePaths="~/G/L" />
  <Tools>
            <telerik:EditorToolGroup Tag="MainToolbar">
                <telerik:EditorTool Name="FindAndReplace" />
                <telerik:EditorSeparator />
                <telerik:EditorTool Name="Undo" />
                <telerik:EditorTool Name="Redo" />
                <telerik:EditorSeparator />
                <telerik:EditorTool Name="Cut" />
                <telerik:EditorTool Name="Copy" />
                <telerik:EditorTool Name="Paste" ShortCut="CTRL+!" />
                <telerik:EditorTool Name="Bold" />
                <telerik:EditorTool Name="Italic" />
                <telerik:EditorTool Name="Underline" />
                <telerik:EditorSeparator />
                <telerik:EditorTool Name="ForeColor" />
                <telerik:EditorTool Name="BackColor" />
                <telerik:EditorSeparator />
                <telerik:EditorTool Name="FontName" />
                <telerik:EditorTool Name="RealFontSize" />
                <telerik:EditorSeparator />
                <telerik:EditorTool Name="ImageManager" />
            </telerik:EditorToolGroup>
  </Tools>

</telerik:RadEditor>

telerik RadEditor ImageManager: Display complete url of image instead of relative url.

ImageManager in Telerik RadEditor adds images to the editor but with related url. which could raise some issues with url rewriting. we can easily resolve this by using ContentFilters attribute. image manager in following editor will add images with complete url only.



<telerik:RadEditor runat="server" ID="EditorImageUrl" ContentFilters="DefaultFilters,MakeUrlsAbsolute">
  <ImageManager DeletePaths="~/DisplayImages" UploadPaths="~/DisplayImages" ViewPaths="~/DisplayImages" />

</telerik:RadEditor>

Telerik Radeditor: ImageManager - display images from multiple folder.

use following code to include ImageManager to a RadEditor and display images from multiple folders:

<telerik:RadEditor ID="RadEditor1" Height="600" runat="server">
  <ImageManager ViewPaths="~/Images/ProfilePics,~/Images/PublicPics" UploadPaths="~/Images/ProfilePics" DeletePaths="~/Images/ProfilePics" />
</telerik:RadEditor>

Friday, December 26, 2014

Get all checkbox checked in gridview/repeater/datalist

Following is the simplest way to get checked checkbox in a grid:

<asp:GridView runat="server" ID="grd" AutoGenerateColumns="false">
  <EmptyDataTemplate>
    No data found
  </EmptyDataTemplate>
  <Columns>
    <asp:TemplateField HeaderStyle-Width="4%">
      <HeaderTemplate>
        <input type="checkbox" id="cbUserAll" title="Select/Unselect All" onclick="SelectAllCB('ckbUser', this);" />
      </HeaderTemplate>
      <ItemTemplate>
        <input type="checkbox" id='ckbUser<%#Eval("Id")%>' name="ckbUser" value='<%#Eval("Id")%>' />
      </ItemTemplate>
In CS page:
  string str = Convert.ToString(Request.Form["ckbuser"]);

This will get all selected checkbox values comma separated.

Wednesday, December 24, 2014

SERVICES.MSC get service status using C#


Description:

Following code can be used to get service (services.msc) status using C#:

static string checkservice(string SERVICENAME)
{
    ServiceController sc = new ServiceController(SERVICENAME);

    switch (sc.Status)
    {
        case ServiceControllerStatus.Running:
            return "Running";
        case ServiceControllerStatus.Stopped:
            return "Stopped";
        case ServiceControllerStatus.Paused:
            return "Paused";
        case ServiceControllerStatus.StopPending:
            return "Stopping";
        case ServiceControllerStatus.StartPending:
            return "Starting";
        default:
            return "Status Changing";
    }
}