Friday, November 25, 2011

RadImage in RadGrid

Problem: How to bind and insert a RadImage in RadGrid  From Server Side using RadAsyncUpload.

Solution:
Here Is The Sample Code.
ASPX

<%@ Page Title="Home Page" Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
    Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body class="BODY">
    <form id="form1" runat="server">
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
    </telerik:RadStyleSheetManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var uploadedFilesCount = 0;
            var isEditMode;
            function validateRadUpload(source, e) {
                debugger;
                if (isEditMode == null || isEditMode == undefined) {
                    e.IsValid = false;

                    if (uploadedFilesCount > 0) {
                        e.IsValid = true;
                    }
                }
                isEditMode = null;
            }

            function OnClientFileUploaded(sender, eventArgs) {
                uploadedFilesCount++;
            }
            function conditionalPostback(sender, eventArgs) {
                var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                if (eventArgs.get_eventTarget().match(theRegexp)) {
                    var upload = $find(window['UploadId']);

                    //AJAX is disabled only if file is selected for upload
                    if (upload.getFileInputs()[0].value != "") {
                        eventArgs.set_enableAjax(false);
                    }
                }
            }
       
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <table width="100%">
        <tr>
            <td>
            </td>
        </tr>
        <tr>
            <td align="center" width="90%">
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                    <AjaxSettings>
                        <telerik:AjaxSetting AjaxControlID="RadGrid1">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                            </UpdatedControls>
                        </telerik:AjaxSetting>
                    </AjaxSettings>
                </telerik:RadAjaxManager>
                <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                    CellSpacing="0" GridLines="None" OnInsertCommand="RadGrid1_InsertCommand" OnItemCreated="RadGrid1_ItemCreated"
                    OnNeedDataSource="RadGrid1_NeedDataSource" PageSize="3" ShowStatusBar="True"
                    Skin="Web20" Width="900px">
                    <PagerStyle AlwaysVisible="true" Mode="NumericPages" />
                    <MasterTableView CommandItemDisplay="Top" Width="900px">
                        <Columns>
                            <telerik:GridTemplateColumn HeaderStyle-Width="190px" HeaderText="Image Name" SortExpression="Name"
                                UniqueName="ImageName">
                                <ItemTemplate>
                                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadTextBox ID="txbName" runat="server" Text='<%# Eval("Name") %>' Width="190px" />
                                    <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ControlToValidate="txbName"
                                        Display="Dynamic" ErrorMessage="Please, enter a name!" SetFocusOnError="true" />
                                </EditItemTemplate>
                                <HeaderStyle Width="190px" />
                                <ItemStyle VerticalAlign="Top" Width="190px" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="Description" HeaderStyle-Width="200px" HeaderText="Description"
                                UniqueName="Description">
                                <ItemTemplate>
                                    <telerik:RadTextBox ID="lblDescription" runat="server" BorderColor="White" Height="60px"
                                        ReadOnly="true" Text='<%# TrimDescription(DirectCast(IIF(Eval("Description") IsNot DBNull.Value,Eval("Description"),string.Empty),String)) %>'
                                        TextMode="MultiLine" Width="200px" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadTextBox ID="txbDescription" runat="server" Height="60px" Text='<%# Eval("Description") %>'
                                        TextMode="MultiLine" Width="180px" />
                                </EditItemTemplate>
                                <HeaderStyle Width="200px" />
                                <ItemStyle VerticalAlign="Top" Width="180px" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderStyle-Width="220px" ItemStyle-Width="220px" HeaderText="Image"
                                UniqueName="Upload">
                                <ItemTemplate>
                                    <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AlternateText='<%#Eval("Name", "Photo of {0}") %>'
                                        AutoAdjustImageControlSize="false" DataValue='<%#Eval("Image") %>' Height="140px"
                                        ToolTip='<%#Eval("Name", "Photo of {0}") %>' Width="220px" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadAsyncUpload ID="AsyncUpload1" runat="server" AllowedFileExtensions="jpg,jpeg,png,gif"
                                        MaxFileSize="5048576" OnClientFileUploaded="OnClientFileUploaded" OnValidatingFile="RadAsyncUpload1_ValidatingFile">
                                    </telerik:RadAsyncUpload>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn ButtonType="ImageButton" />
                        </EditFormSettings>
                        <PagerStyle AlwaysVisible="True" />
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Web20">
                    </HeaderContextMenu>
                </telerik:RadGrid>
            </td>
        </tr>
    </table>
</body>
</form>
</html>

VB Code.
Imports System.Data
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page 
Const MaxTotalBytes As Integer = 1024 ' 1 MB
    Dim totalBytes As Integer
    Dim ConnString As String = "data source=localDataSource;Initial Catalog=database;User Id=User;Password=*****;"

    Dim sqlconn As New SqlConnection(ConnString)


    Public Property IsRadAsyncValid() As System.Nullable(Of Boolean)
        Get
            If Session("IsRadAsyncValid") Is Nothing Then
                Session("IsRadAsyncValid") = True
            End If

            Return Convert.ToBoolean(Session("IsRadAsyncValid").ToString())
        End Get
        Set(ByVal value As System.Nullable(Of Boolean))
            Session("IsRadAsyncValid") = value
        End Set
    End Property
    Protected Function TrimDescription(ByVal description As String) As String
        If Not String.IsNullOrEmpty(description) AndAlso description.Length > 200 Then
            Return String.Concat(description.Substring(0, 200), "...")
        End If
        Return description
    End Function

 
    Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs)
        If Not IsRadAsyncValid.Value Then
            e.Canceled = True
            RadAjaxManager1.Alert("The length of the uploaded file must be less than 1 MB")
            Return
        End If

        Dim insertItem As GridEditFormInsertItem = TryCast(e.Item, GridEditFormInsertItem)
        Dim imageName As String = TryCast(insertItem("ImageName").FindControl("txbName"), RadTextBox).Text
        Dim description As String = TryCast(insertItem("Description").FindControl("txbDescription"), RadTextBox).Text
        Dim radAsyncUpload As RadAsyncUpload = TryCast(insertItem("Upload").FindControl("AsyncUpload1"), RadAsyncUpload)

        Dim file As UploadedFile = radAsyncUpload.UploadedFiles(0)
        Dim fileData As Byte() = New Byte(file.InputStream.Length - 1) {}
        file.InputStream.Read(fileData, 0, CInt(file.InputStream.Length))
        sqlconn.Open()
        Dim Insert As New SqlCommand("Insert into [Test1].[dbo].[Test_Img] ([ImageID],[Name],[Description],[Image]) values ('3','" + imageName + "','" + description + "',  @image  )", sqlconn)
        Dim imageParam As SqlParameter = Insert.Parameters.Add("@image", SqlDbType.Image)
        imageParam.Value = fileData
        imageParam.Size = fileData.Length
        Insert.ExecuteNonQuery()
        sqlconn.Close()

      End Sub

    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource

        Dim SqlCommand As New SqlCommand("Select [ImageID],[Image],[Name],[Description] from [Test1].[dbo].[Test_Img]", sqlconn)
        sqlconn.Open()
        Dim sqladap As New SqlDataAdapter
        sqladap.SelectCommand = SqlCommand
        Dim ds As New DataSet
        sqladap.Fill(ds, "ImageSet")

        RadGrid1.DataSource = ds.Tables(0)
        sqlconn.Close()

    End Sub

    Public Sub RadAsyncUpload1_ValidatingFile(ByVal sender As Object, ByVal e As Telerik.Web.UI.Upload.ValidateFileEventArgs)
        If (totalBytes < MaxTotalBytes) AndAlso (e.UploadedFile.ContentLength < MaxTotalBytes) Then
            e.IsValid = True
            totalBytes += e.UploadedFile.ContentLength
            IsRadAsyncValid = True
        Else
            e.IsValid = False
            IsRadAsyncValid = False
        End If
    End Sub
    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim upload As RadAsyncUpload = TryCast(DirectCast(e.Item, GridEditableItem)("Upload").FindControl("AsyncUpload1"), RadAsyncUpload)
            Dim cell As TableCell = DirectCast(upload.Parent, TableCell)

            Dim validator As New CustomValidator()
            validator.ErrorMessage = "Please select file to be uploaded"
            validator.ClientValidationFunction = "validateRadUpload"
            validator.Display = ValidatorDisplay.Dynamic
            cell.Controls.Add(validator)
        End If

    End Sub
End Class

C# Code.
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using Telerik.Web.UI;
using System.Data.SqlClient;
partial class _Default : System.Web.UI.Page
{

  // 1 MB
 const int MaxTotalBytes = 1024;
 int totalBytes;

 string ConnString = "data source=localDataSource;Initial Catalog=database;User Id=User;Password=*****;";

 SqlConnection sqlconn = new SqlConnection(ConnString);

 public System.Nullable<bool> IsRadAsyncValid {
  get {
   if (Session["IsRadAsyncValid"] == null) {
    Session["IsRadAsyncValid"] = true;
   }

   return Convert.ToBoolean(Session["IsRadAsyncValid"].ToString());
  }
  set { Session["IsRadAsyncValid"] = value; }
 }
 protected string TrimDescription(string description)
 {
  if (!string.IsNullOrEmpty(description) && description.Length > 200) {
   return string.Concat(description.Substring(0, 200), "...");
  }
  return description;
 }


 protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
 {
  if (!IsRadAsyncValid.Value) {
   e.Canceled = true;
   RadAjaxManager1.Alert("The length of the uploaded file must be less than 1 MB");
   return;
  }

  GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem;
  string imageName = (insertItem("ImageName").FindControl("txbName") as RadTextBox).Text;
  string description = (insertItem("Description").FindControl("txbDescription") as RadTextBox).Text;
  RadAsyncUpload radAsyncUpload = insertItem("Upload").FindControl("AsyncUpload1") as RadAsyncUpload;

  UploadedFile file = radAsyncUpload.UploadedFiles(0);
  byte[] fileData = new byte[file.InputStream.Length];
  file.InputStream.Read(fileData, 0, Convert.ToInt32(file.InputStream.Length));
  sqlconn.Open();
  SqlCommand Insert = new SqlCommand("Insert into [Test1].[dbo].[Test_Img] ([ImageID],[Name],[Description],[Image]) values ('3','" + imageName + "','" + description + "',  @image  )", sqlconn);
  SqlParameter imageParam = Insert.Parameters.Add("@image", SqlDbType.Image);
  imageParam.Value = fileData;
  imageParam.Size = fileData.Length;
  Insert.ExecuteNonQuery();
  sqlconn.Close();

 }


 protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
  SqlCommand SqlCommand = new SqlCommand("Select [ImageID],[Image],[Name],[Description] from [Test1].[dbo].[Test_Img]", sqlconn);
  sqlconn.Open();
  SqlDataAdapter sqladap = new SqlDataAdapter();
  sqladap.SelectCommand = SqlCommand;
  DataSet ds = new DataSet();
  sqladap.Fill(ds, "ImageSet");

  RadGrid1.DataSource = ds.Tables[0];
  sqlconn.Close();

 }

 public void RadAsyncUpload1_ValidatingFile(object sender, Telerik.Web.UI.Upload.ValidateFileEventArgs e)
 {
  if ((totalBytes < MaxTotalBytes) && (e.UploadedFile.ContentLength < MaxTotalBytes)) {
   e.IsValid = true;
   totalBytes += e.UploadedFile.ContentLength;
   IsRadAsyncValid = true;
  } else {
   e.IsValid = false;
   IsRadAsyncValid = false;
  }
 }
 protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
  if (e.Item is GridEditableItem && e.Item.IsInEditMode) {
   RadAsyncUpload upload = (GridEditableItem)e.Item("Upload").FindControl("AsyncUpload1") as RadAsyncUpload;
   TableCell cell = (TableCell)upload.Parent;

   CustomValidator validator = new CustomValidator();
   validator.ErrorMessage = "Please select file to be uploaded";
   validator.ClientValidationFunction = "validateRadUpload";
   validator.Display = ValidatorDisplay.Dynamic;
   cell.Controls.Add(validator);
  }

 }
}


Thursday, November 24, 2011

Open RadWindow from server side programming


Problem: How to open RadWindow from server side programming
Solution: It is very simple and can be done in following steps,
Step1: Create a ASPX Page which will be open as RadWindow in project e.g "Windowsvb.aspx"
The Page Must Be On Same Directory Where Your Current Page(Calling Rad Window) e.g "Default.aspx" Exist . Not Neccessary But The Code Bellow Work On This Condition

Step2: In Your Current Page "Default.aspx.vb" Write The Function.Given bellow
Protected Sub CreateWindowScript() 
        Dim window1 As New RadWindow()
        window1.NavigateUrl = "Windowsvb.aspx" ' The Path  Be Same As Created In Project
        window1.VisibleOnPageLoad = True
        window1.Width = 950
        window1.Height = 700
        window1.Modal = True
        window1.Behaviors = WindowBehaviors.Close 
        window1.Visible = True
        window1.VisibleOnPageLoad = True
        window1.AutoSize = False
        window1.VisibleStatusbar = True 
        Me.form1.Controls.Add(window1)
End Sub

'You can call this function from any event e.g Click Button Event etc

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        CreateWindowScript()
End Sub


'The DOM Which IS calling This Function Must Not BE In RadAjaxManager OR RadAjaxPanel

Tuesday, November 22, 2011

Server Side Binding Of Telerik RadGrid


Problem: I want To Bind Telerik RadGrid From Server Side.
Solution: Its very ,simple and easy to bind RadGrid from server-side,Use NeedDataSource.NeedDataSource event is called whenever RadGrid is performing some operation like sorting,filtering etc.
Here is the sample code ,hope it works.
ASPX Code:
 <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" >
   <MasterTableView  Width="100%" GridLines="None"  >
 <Columns>
   <telerik:GridTemplateColum  HeaderText="Name"   UniqueName="Name">
             
                 <ItemTemplate>
<asp:Label ID="Name" runat="server" Text='<%# eval("Name") %>'></asp:Label>
  </ItemTemplate>
             </telerik:GridTemplateColumn>
   </Columns>
            </MasterTableView>
     </telerik:RadGrid>

VB Code:
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
      
Dim Ds as DataSet
Ds=GetDataSETFromDataBase '  Use Function Or Procedure You Use To Fetch Data SET From DataBase
  RadGrid1.DataSource = Ds.Tables(0)

End Sub














Friday, November 18, 2011

RadComboBox not to select any Item on Load

Problem: I am trying to set SelectedIndex to -1 with the objective that I don't any item in the RadCombo to be highlighted. Whilst the debugger passes the line the next statement says SelectedIndex 0.
How to make the RadCombo not to select any particular item automatically?
Solution: To avoid automatic selection of RadComboBox you can try any of the following approaches.
1) Set EmptyMessage property.
or
2) Add an empty text as first RadComboBoxItem.
Here is the sample ASPX,
<telerik:RadComboBox ID="RadComboBox1" runat="server"
            AutoPostBack="true"  Skin="Sunset" EnableAjaxSkinRendering="false"  >
      <Items>
            <telerik:RadComboBoxItem Text="" Value="-1" />
            <telerik:RadComboBoxItem Text="Telerik School Item 1" Value="0"  >
            </telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem Text="Telerik School Item 2" Value="1">
            </telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem Text="Telerik School Item 3" Value="2">
            </telerik:RadComboBoxItem>
            <telerik:RadComboBoxItem Text="Telerik School Item 4" Value="3">
            </telerik:RadComboBoxItem>
     </Items>     
</telerik:RadComboBox>

RadComboBox EnableLoadOnDemand

Problem: I created radcombobox dynamically. I want to add EnableLoadOnDemand functionality from codebehind. I need a sample of code in asp.net having this functionality doing from codebehind.
Solution: To see how RadComboBox is bound to various data sources, you could refer to the DataBinding section of the Combo's online documentation.

To enable the load on demand functionality, you need to set the property LoadOnDemand to true, and subscribe to the OnItemsRequested server-side event, where the items will be populated when they are requested on demand (which happens when the user opens the drop-down list, or type in the input field), as in the code-block below:
protected void Page_Load(object sender, EventArgs e)
{
    RadComboBox combo = new RadComboBox();
    combo.ID = "RadComboBox1";
    combo.EnableLoadOnDemand = true;
    combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(combo_ItemsRequested);
    form1.Controls.Add(combo);
}
protected void combo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
    RadComboBox combo = (RadComboBox)sender;
    for (int i = 0; i <= 3; i++)
    {
        combo.Items.Add(new RadComboBoxItem("item_" + i.ToString()));
    }
}

Sunday, November 13, 2011

How to filter record on RadGrid by only one column

Problem: When i set AllowFilteringByColumn property of RadGrid to "True", all columns can be filtered. What i want to do is to filter records by only one column. How can i do that?
Solution: You can set the AllowFitering property for the every column other than the one with which you want to filter the grid to false.

Example:
<radG:GridBoundColumn AllowFiltering="false" DataField="ContactName" UniqueName="BoundColumnUniqueName" HeaderText="ContactName">
</radG:GridBoundColumn>

Friday, November 11, 2011

Remove mouse cursor from RadComboBox

Problem: How to remove the blinking mouse cursor from the RadComboBox ?
Solution: You want to prevent to type in RadComboBox. You could try setting AllowCustomText property of the RadComboBox to false which prevents typing any text in the input of the RadComboBox. Also set the EnableLoadOnDemand and MarkFirstMatch properties to false.

Thursday, November 10, 2011

Label to filter in GridTemlpateColumn

Problem: I want to filter an ASP label
"<asp:Label  runat="server" Text='<%# eval("AnyThing") %>' ></asp:Label>"
in Telerik GridTemplateColumn .Also I dont want Filter Icon to display and I Want "Contains" Filter Function.

Sloution: Just give DataField="DataFieldName" in GridTemplateColumn.The DataField Name which you are using to evaluate Label

Example:
<asp:Label ID="lblName" runat="server" Text='<%# eval("Name")></asp:Label>
Must be given to DataField e.g DataField="Name".
The Green Highlighted Text Is For Filter Icon To Hide and For Filtering With "Contains" 
The Aqua Highlighted  text is For Filtering a String From  Label

Yellow  Is Common For Both

Here Is The Sample Code:


<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   >
           <MasterTableView  AllowFilteringByColumn="True"  >
                    <Columns>
                             <telerik:GridTemplateColumn AllowFiltering="true"   AutoPostBackOnFilter="true" HeaderText="Name" datafield="Name" DataType="System.String"
ShowFilterIcon="false"   CurrentFilterFunction="Contains" UniqueName="Name" >
                                         <ItemTemplate>
                                                   <asp:Label ID="lblName" runat="server" Text='<%# eval("Name") %>'>
                                                   </asp:Label>
                                         </ItemTemplate>
                             </telerik:GridTemplateColumn>
                    </Columns>
           </MasterTableView>
</telerik:RadGrid>
               


Wednesday, November 9, 2011

TextBox in GridTemplateColumn

Problem: I want to filter an ASP TextBox
"<asp:TextBox ID="TXTName" runat="server" Text='<%# eval("Name") %>'  ></asp:TextBox>"
in Telerik GridTemplateColumn .Also I dont want filter Icon to display and I Want "StartsWith" Filter Function.

Sloution: Just give DataField="DataFieldName" in GridTemplateColumn.The DataField Name which you are using to evaluate TextBox.

Example:
<asp:TextBox ID="TXTName" runat="server" Text='<%# eval("Name") %>'  ></asp:TextBox>
Must BE Given To DataField e.g DataField="Name".
The Green Highlighted Text Is For Filter Icon To Hide and  For Filtering With "StartsWith" 
The Aqua Highlighted text is For Filtering a String From Label

Yellow Is Common For Both

Here Is The Sample Code:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"   >
            <MasterTableView  AllowFilteringByColumn="True"  >
                     <Columns>                 
                           <telerik:GridTemplateColumn AllowFiltering="true"   AutoPostBackOnFilter="true" HeaderText="Name" datafield="Name" DataType="System.String"
ShowFilterIcon="false"   CurrentFilterFunction="StartsWith" UniqueName="Name" >
                                     <ItemTemplate>
                                        <asp:TextBox ID="TXTName" runat="server" Text= '<%# eval("Name") %>' >
                                        </asp:TextBox>
                                     </ItemTemplate>
                            </telerik:GridTemplateColumn>
                    </Columns>
            </MasterTableView>
</telerik:RadGrid>
               

Right to left support in telerik

Problem: How to set Right to left in different controls of telerik ?
Solution: 
Right to left support in Telerik


Here is the sample code

Monday, November 7, 2011

How To Get SelectedValue Of RadComboBox From Java Script


Problem: How to get SelectedValue Of RadComboBox using Java Script ?
Solution: Place this Script in the Head tag,

 <script type="text/javascript">
    function GetSelectedValueOfRadComboBox() {
        var radcmb = $find("RadComboBox1");  // Find The Object By  ID 
        var value = radcmb.get_value();  // Get_Value() Is telerik Library Included Function
        Return value;
    }
</script>

Sunday, November 6, 2011

Radcalendar having different weekend like (friday,saturday)

Problem: How can we make different weekends like Friday and Saturday in RadCalender ?
Solution: There are two ways,
1) You can do in source of Page like

<telerik:RadCalendar ID="RadCalendar1" Runat="server" FirstDayOfWeek="Thursday">
</telerik:RadCalendar>
RadCalender
Here you can see that Thursday became the first day of week.

RadDatePicker not taking the value from keyboard

Problem: You have noticed that when you pick the value from calender pop up button then it works fine. But when you enter the value through keyboard like 1/1/1920 it does not work.
RadDatePicker

Solution: Remember RadCalender default minimum date is 1/1/1980.So if you give a date less than 1980 it will will not understand the date.


Example:

<telerik:RadDatePicker ID="Datepicker1" Width="100px" runat="server" MinDate="01/01/1900"
     MaxDate="12/31/2100">
</telerik:RadDatePicker>

Saturday, November 5, 2011

~/Telerik.Web.UI.WebResource.axd' is missing in web.config

Problem: When you place RadScriptManager on aspx page and compile it gives error like, 
" '~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager "


Solution: Its Simple And fast you Just Have to register The radScriptmanager and it will modify the web config file automatically.
Example:

  • Click RadScriptManager Menu Cursor .It Will Display RadScript Manager Tasks click on Regiter Telerik.Web>UI.WebResource.axd

Telerik.Web.UI.WebResource.axd

  • Telerik.WebUI.WebResources.axd Is Now Succeessfully Register in Web Config.
Telerik.Web.UI.WebResource.axd




To apply client side validation on RadGrid Update or Insert button

Problem: To call any javascript(Client Side) on click of UpdateButton or InsertButton of RadGrid like this image,

Solution: Here is the code

Problem Using Telerik Project

Problem: When I up the website it is showing a strange behaviour, sometimes comboboxes are not working ,sometimes problem in RadGrid.It is running perfectly at local server.
Here is sample code,
<body>
    <form runat="server">
           <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
           <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" />
...........
           <telerik:RadGrid ID="RadGrid1" runat="server">
           </telerik:RadGrid>
...........
    </form>
</body>
Solution: It is because you are using RadScriptManager and it is conflicting with Telerik.StyleSheetManager.TelerikCdn.You can do EnableScriptCombine="false" and EnableHandlerDetection="false" (properties of RadScriptManager).
Here is sample code,
<body>
    <form runat="server">
           <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableScriptCombine="false" EnableHandlerDetection="false"></telerik:RadScriptManager>
           <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" />
...........
           <telerik:RadGrid ID="RadGrid1" runat="server">
           </telerik:RadGrid>
...........
    </form>
</body>

Friday, November 4, 2011

Client Side Validation of RadDatePicker

Problem: How to validate two RadDatePicker Controls for example "From Date" can
not be greater than "To Date".
Solution: It can be done by using asp validation controls like RequiredFieldValidator and CompareValidator. RequiredFieldValidator checks that whether value(date) is present or not. And CompareValidator compares the two values. Here is the sample code,

Tuesday, November 1, 2011

RadDatePicker enable/disable through javascript

Problem: How to enable/disable RadDatePicker through javascript ?
Solution: You can make use of the client side method set_enabled to false.

Example:
function disable()
  {
      var dateinput = $find("<%= RadDatePicker1.ClientID %>");
      dateinput.set_enabled(false);
  }

Also refer the following documentation for more on the RadDatePicker Client Object.
RadDatePicker Client Object