Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
158 views
I have an asp.net app using some Telerik controls - such as the RadTabStrip.
I got a notice for an auto-update to the controls when booting up the project this morning, and let it do its thing.  Now I get an error that the embedded "Forest" skin cannot be found in my RadTabStrip.  What am I missing here?
Telerik.Web.UI.RadTabStrip with ID='rtsMain' was unable to find embedded skin with name 'Forest'.
Kate
Telerik team
 answered on 09 Dec 2011
3 answers
190 views
Hi All,

I would be working in a web application project wherein am going to make extensive usage of chart control provided by RadGrid.
I happened to look through most of the demonstrations provided by Telerik for the ASP.Net Ajax Chart control.

I would like to know whether the chart control supports moving (or) dragging of points in a line chart which would trigger a change in the position of the vertices.

The dragging event could either be a server side or a client side event. However, only specific points should be draggable depending upon some set of criterias.

Also, the datasource for the line chart is expected to be dynamic. Is it possible to achieve such a functionality using the chart control? Any insights?
Evgenia
Telerik team
 answered on 09 Dec 2011
3 answers
159 views
Hello,
        I wanted to know whether in the grid are you able to make the entire column editable? My requirement is that on page load I need to show few columns of the grid as editable. The editable columns contain either a combobox, a date type textbox or the simple textbox.
Rest of the columns should not be editable.

Also I have another question, how to get the cell index when I click on a particular cell of the grid. Or if I enter some data into the cell, is it possible to get the cell id for that particular cell from client side?

Thank You
Amruta Deshpande
Iana Tsolova
Telerik team
 answered on 09 Dec 2011
3 answers
104 views
Is there any way to have a grouping functionality on the TreeList Control?
Do you plan to add grouping in next release?
Or how can i go around it?
Sebastian
Telerik team
 answered on 09 Dec 2011
6 answers
234 views
Hi

I have found an issue where I cannot get  ClientEvents-OnResponseEnd="onResponseEnd" ClientEvents-OnRequestStart="onResponseStart" events to fire in javascript when I do a manual postback - however the server side event code does run in ajax mode.

for instance I have an asp button in a page with a server event wrapped in an ajax panel with the 2 javascript events wired up.

If I use the mouse to click the button then it works fine - both the onResponseStart and onResponseEnd javascript functions work.

However in the folloiwng situation I want to click the button in code and not with the mouse. In this case I have wired an event for the <CR> key being clicked in a radtextbox to fire the mouse click event of the button as follows

ASCX FILE Rad Text Box that allows <CR> to be pressed and then runs the __dopostback code for a button click
             <telerik:RadTextBox ID="bxPNCID" runat="server" SelectionOnFocus="SelectAll" Skin="Vista"
              Width="200px" onkeydown="return OverridePostBackOnEnter(event, 'ImageButton6')">
             </telerik:RadTextBox>

ASCX IMAGEBUTTON 6 - The button Click I want to emulate - I needed ClientIDMode="Static" because document.getelementbyid function needs the rendered ID rather than the aspx ID
          <asp:ImageButton ID="ImageButton6" ClientIDMode="Static" runat="server" Style="float: right;
           margin-top: -44px" ImageUrl="images/butt_searchcustrecoff.png" AlternateText="Search Custody Records"
           ToolTip="Search Record" OnClick="SearchRecords_Click" />

JAVASCRIPT FUNCTION TO HANDLE THE KEYPRESS AND CONVERT TO MOUSE CLICK
        //attach OverridePostBackOnEnter to keypress of textbox
        //onkeypress="OverridePostBackOnEnter(event, 'Id of click button')" -- Firefox
        //onkeydown="OverridePostBackOnEnter(event, 'Id of click button')" -- IE
        //Remember set 'ClientIdMode' of controlling button to 'STATIC'
        function OverridePostBackOnEnter(event, ctrl)
        {
            if (event.keyCode == 13)
            {
                if ($.browser.mozilla)
                {
                    var overridectrl = document.getElementById(ctrl);
                    __doPostBack(overridectrl.name, '');
                }
                else
                { //for IE
                    //but for other browsers you should use
                    var overridectrl = document.getElementById(ctrl);
                    __doPostBack(overridectrl.name, ''); // everything I have researched says it should be uniqueID for IE but does not seem to fire the server event
                }
            }
        };

to summarise the code above then
the radtextbox has the onkeydown event fire
the JS Routine OverridePostBackOnEnter(event, ctrl) runs  and checks for the key being <CR>
The JS Routine then does the __doPostBack event.
(AjaxPanel Runs The OnResponseStart Function - DOES NOT HAPPEN)
The Server Code runs the mouse click event.
(AjaxPanel Runs The OnResponseEnd Function - DOES NOT HAPPEN)

The ajax control did not fire the onResponseStart and onResponseEnd javascript routines which do run if I click button6 using the mouse.

Any help greatly appreciated guys.

regrads Mick.
Mick
Top achievements
Rank 1
 answered on 09 Dec 2011
6 answers
250 views
Hi,

if have create a class inherits from GridBoundColumn and tryed to add custom controls (2 datetime picker and one reset button).
But I down't know whats wrong, because the filtering does not work.

Can someone explain how to do this right?

Here is the code:
public class DateTimeColumn : GridBoundColumn
    {
        #region Fields
         
        SPField _field;
        const string _TRACECONST = "ECSpand.SharePoint.UI.WebUserControls.RecordsOrganizer.FileContent.Columns.DateTimeColumn";
        SPDateTimeFieldFormatType _formatType = SPDateTimeFieldFormatType.DateTime;
        private RadDatePicker _datePickerFrom;
        private RadDatePicker _datePickerTo;
         
 
        #endregion
 
        #region Constructor ()
 
        public DateTimeColumn()
        {
 
        }
 
        #endregion
 
        #region Constructor (field)
 
        public DateTimeColumn(SPField field)
        {
            this.AllowSorting = true;
            this.DataField = field.Id.ToString();
            this.HeaderText = field.Title;
            this.HeaderTooltip = "";
            _field = field;
            this.SortExpression = field.Id.ToString();
            SPFieldDateTime dtField = field as SPFieldDateTime;
            if (dtField != null)
            {
                _formatType = dtField.DisplayFormat;
            }
        }
 
        #endregion
 
        #region Methods
         
        #region FormatDataValue (dataValue, item)
 
        protected override string FormatDataValue(object dataValue, GridItem item)
        {
            if (_field == null)
                return dataValue.ToString();
 
            string s = dataValue as string;
            if (!string.IsNullOrEmpty(s))
            {
                try
                {
                    SPWeb web = SPContext.Current.Web;
                    SPRegionalSettings settings = web.RegionalSettings;
                    if (web.CurrentUser.RegionalSettings != null)
                    {
                        settings = web.CurrentUser.RegionalSettings;
                    }
 
                    DateTime time;
                    if (s.Contains('T') || s.Contains('Z'))
                    {
                        time = DateTime.Parse(s, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        time = DateTime.ParseExact(s, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                    if (_formatType == SPDateTimeFieldFormatType.DateOnly)
                    {
                        return time.ToShortDateString();
                    }
                    else
                    {
                        return Microsoft.SharePoint.Utilities.SPUtility.FormatDate(SPContext.Current.Web, time.ToUniversalTime(), Microsoft.SharePoint.Utilities.SPDateFormat.DateTime);
                    }                   
                }
                catch (Exception ex)
                {
                    Log.WriteWarning("DateTime-Field '" + _field.InternalName + "' could not be parsed. Value was + '" + dataValue as string + "'. Exception was : " + ex.ToString(), _TRACECONST);
                    return dataValue as string;
                }
            }         
            return "-";
        }
 
        #endregion
 
        #region  SetupFilterControls (cell)
 
        /// <summary>
        /// RadGrid will call this method when it initializes the controls inside the filtering item cells
        /// </summary>
        /// <param name="cell">The TableCell</param>
        protected override void SetupFilterControls(System.Web.UI.WebControls.TableCell cell)
        {
            base.SetupFilterControls(cell);
            if (cell.Controls.Count > 0)
                cell.Controls.RemoveAt(0);
 
            //cell.Style.Add(HtmlTextWriterStyle.WhiteSpace, "nowrap");
 
            _datePickerFrom = new RadDatePicker();
            //_datePickerFrom.ID = "ColumnFilterDateFrom" + Guid.NewGuid().ToString();
            _datePickerFrom.AutoPostBack = true;
            _datePickerFrom.Skin = "Office2007";
            _datePickerFrom.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(_datePicker_SelectedDateChanged);
            _datePickerFrom.ShowPopupOnFocus = true;
            _datePickerFrom.Width = Unit.Pixel(100);
            _datePickerFrom.EnableScreenBoundaryDetection = false;
            _datePickerFrom.DatePopupButton.ToolTip = string.Empty;
            _datePickerFrom.Style.Add(HtmlTextWriterStyle.MarginRight, "5px");
            _datePickerFrom.EnableTyping = false;
 
            _datePickerTo = new RadDatePicker();
            _datePickerTo.ID = "ColumnFilterDateFrom" + Guid.NewGuid().ToString();
            _datePickerTo.AutoPostBack = true;
            _datePickerTo.Skin = "Office2007";
            _datePickerTo.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(_datePicker_SelectedDateChanged);
            _datePickerTo.ShowPopupOnFocus = true;
            _datePickerTo.Width = Unit.Pixel(100);
            _datePickerTo.EnableScreenBoundaryDetection = false;
            _datePickerTo.DatePopupButton.ToolTip = string.Empty;
            _datePickerTo.Style.Add(HtmlTextWriterStyle.MarginRight, "5px");
            _datePickerTo.EnableTyping = false;
 
            ImageButton resetfilterbutton = new ImageButton();
            if (!string.IsNullOrEmpty(this.CurrentFilterValue) && this.CurrentFilterFunction != GridKnownFunction.NoFilter)
                resetfilterbutton.ImageUrl = "/_layouts/images/ecspand/filter_remove_green.png";
            else
                resetfilterbutton.Visible = false;
            resetfilterbutton.Width = Unit.Pixel(16);
            resetfilterbutton.Height = Unit.Pixel(16);
            resetfilterbutton.Click += new ImageClickEventHandler(resetfilterbutton_Click);
 
            cell.Controls.AddAt(0, _datePickerFrom);
            cell.Controls.AddAt(1, _datePickerTo);
            cell.Controls.AddAt(2, resetfilterbutton);
            if (cell.Controls.Count > 3)
                cell.Controls.RemoveAt(3);
        }
 
        #endregion
 
        #region _datePicker_SelectedDateChanged (sender, e)
 
        private void _datePicker_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
        {
            GridFilteringItem filterItem = (GridFilteringItem)((RadDatePicker)sender).NamingContainer;
            try
            {
                if (_datePickerFrom.SelectedDate != null && _datePickerTo.SelectedDate == null)
                    _datePickerTo.SelectedDate = _datePickerFrom.SelectedDate.Value.AddHours(12);
                 
                if (_datePickerFrom.SelectedDate != null && _datePickerTo.SelectedDate != null)
                {
                    filterItem.FireCommandEvent("Filter", new Pair(GridKnownFunction.Between.ToString(), this.UniqueName));
                }
                else
                    filterItem.FireCommandEvent("Filter", new Pair("NoFilter", this.UniqueName));
            }
            catch
            {
            }
        }
 
        #endregion
 
        #region resetfilterbutton_Click (sender, e)
 
        /// <summary>
        /// Handles the Click event of the resetbutton to reset the current column filter.
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The ImageClickEventArgs</param>
        private void resetfilterbutton_Click(object sender, ImageClickEventArgs e)
        {
            if (_datePickerFrom != null)
            {
                this.CurrentFilterValue = string.Empty;
                this.CurrentFilterFunction = GridKnownFunction.NoFilter;
                GridFilteringItem filterItem = (GridFilteringItem)((RadDatePicker)_datePickerFrom).NamingContainer;
                filterItem.FireCommandEvent("Filter", new Pair("NoFilter", this.UniqueName));
            }
        }
 
        #endregion
 
        #region  GetCurrentFilterValueFromControl (cell)
 
        /// <summary>
        /// RadGrid will call this method when the filtering value should be extracted from the filtering input control(s)
        /// </summary>
        /// <param name="cell">The TableCell</param>
        /// <returns>The current filter value</returns>
        protected override string GetCurrentFilterValueFromControl(TableCell cell)
        {
            if (_datePickerFrom.SelectedDate != null)
            {
                string data = string.Format("{0} {1}",  _datePickerFrom.SelectedDate.Value, _datePickerTo.SelectedDate.Value);
 
                return data;
            }
            else
                return string.Empty;
        }
 
        #endregion
 
        #region SetCurrentFilterValueToControl (cell)
 
        /// <summary>
        /// RadGrid will call this method when the value should be set to the filtering input control(s)
        /// </summary>
        /// <param name="cell">The TableCell</param>
        protected override void SetCurrentFilterValueToControl(TableCell cell)
        {
            if (_datePickerFrom != null)
            {
                base.SetCurrentFilterValueToControl(cell);
                if (!string.IsNullOrEmpty(this.CurrentFilterValue))
                {
                    _datePickerFrom.SelectedDate = this.GetDateTimeValueFormCurrentFilterValue(this.CurrentFilterValue);
                }
            }
        }
 
        #endregion
 
        #region GetDateTimeValueFormCurrentFilterValue (value)
 
        private DateTime? GetDateTimeValueFormCurrentFilterValue(string value)
        {
            DateTime? retval = null;
 
            if (!string.IsNullOrEmpty(value))
            {
                DateTime tmp = DateTime.MinValue;
                if (DateTime.TryParse(value, out tmp))
                    retval = Convert.ToDateTime(tmp);
            }
 
            return retval;
        }
 
        #endregion
 
        #endregion
    }

Best regards,
Ralf



Iana Tsolova
Telerik team
 answered on 09 Dec 2011
1 answer
80 views
When I enable static headers in my TreeList, the HeaderTemplate contents from  TreeListTemplateColumn from an Item do not expand and contract as the width of the tree list changes. If you look at the way the TreeList renders it's "_rtlHeader" div when in scroll mode, you see a fixed width set (width: 908px) in this case ). This value does not change as the tree list is resized. The item rows, and the other parts of the tree list properly resize ( mostly because they are all set to %'s). I tried to use HeaderStyle to override, and set it to 100%, but it has no effect. Are you having to hard code the width px due to the scrolling, and perhaps forgot an event handler to update this value on change? Is this a bug?

<div id="ctl00_MainContent_RadTreeList1_rtlHeader" class="rtlHeader" style="width: 908px; padding-right: 17px; "><div class="rtlScroller">
        <table cellspacing="0" class="rtlTable rtlHBorders rtlVBorders rtlHVBorders">
            <colgroup>
<col style="width:23px;">
<col style="width:23px;">
<col style="width:23px;">
<col style="width:100%;">
</colgroup>
<thead>
                <tr class="rtlHeader">
                    <th scope="col" class=" rtlCF  rtlCL   " colspan="4">
                    <table width="100%">
                        <tbody><tr>
                            <td align="left" valign="top" style="width:100px; text-align:right">
                                <span style="font-weight:bold">Package: </span><br>
                                <span style="font-weight:bold">Document: </span><br>
                                <span style="font-weight:bold">Checklist: </span>
                            </td>
                            <td align="left" valign="top" style="white-space: nowrap;">
                                <span id="ctl00_MainContent_RadTreeList1_ctl02_lblPackageInfo">asd</span><br>
                                <span id="ctl00_MainContent_RadTreeList1_ctl02_lblDocumentInfo">asd2</span><br>
                                <span id="ctl00_MainContent_RadTreeList1_ctl02_lblCheckListInfo">Test2.a  Checklist on 10/31/2011</span>
                            </td>
                            <td align="center" valign="middle" style="width:100%">
                             <span id="ctl00_MainContent_RadTreeList1_ctl02_lblCompletionStatusText">3 of 3 complete.</span><br>
                             <div id="ctl00_MainContent_RadTreeList1_ctl02_RadSlider1" class="RadSlider RadSlider_Office2007" style="height:22px;width:200px;">
                        <input id="ctl00_MainContent_RadTreeList1_ctl02_RadSlider1_ClientState" name="ctl00_MainContent_RadTreeList1_ctl02_RadSlider1_ClientState" type="hidden" value="{"value":3,"selectionStart":3,"selectionEnd":0,"isSelectionRangeEnabled":false,"orientation":0,"smallChange":1,"largeChange":0,"trackMouseWheel":true,"showDragHandle":false,"showDecreaseHandle":false,"showIncreaseHandle":false,"width":"200px","height":"22px","animationDuration":100,"minimumValue":0,"maximumValue":3,"trackPosition":1,"liveDrag":true,"dragText":"Drag","thumbsInteractionMode":1}" autocomplete="off">
                    <div id="RadSliderWrapper_ctl00_MainContent_RadTreeList1_ctl02_RadSlider1" unselectable="on" style="width: 200px; height: 22px; " class="rslHorizontal"><div unselectable="on" id="RadSliderTrack_ctl00_MainContent_RadTreeList1_ctl02_RadSlider1" class="rslTrack" style="left: 0px; width: 198px; height: 6px; "><div unselectable="on" id="RadSliderSelected_ctl00_MainContent_RadTreeList1_ctl02_RadSlider1" class="rslSelectedregion" style="width: 198px; "><!-- --></div></div></div></div>    
                            </td>
                            <td align="right" valign="top" style="white-space: nowrap;">
                                <a href="javascript:void(0)" class="rfdSkinnedButton"><input type="submit" name="ctl00$MainContent$RadTreeList1$ctl02$btnMarkChecklistAsComplete" value="Mark Checklist as Complete" id="ctl00_MainContent_RadTreeList1_ctl02_btnMarkChecklistAsComplete" class="rfdDecorated" tabindex="-1"></a>
                                 
                            </td>
                        </tr>
                    </tbody></table>
                </th>
                </tr>
            </thead><tbody style="display:none;">
                <tr>
                    <td colspan="1"> </td>
                </tr>
            </tbody>
        </table></div></div>
Andrey
Telerik team
 answered on 09 Dec 2011
4 answers
432 views
I am using RadControls for ASP.NET AJAX Q1 2010 SP1 for the project I am working on.

I am trying to use the RadStyleSheetManager to consolodate and compress my external css files. In my master page, inside the <form> tag I am trying to add the following:
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" OutputCompression="AutoDetect">
    <StyleSheets>
        <telerik:StyleSheetReference IsCommonCss="False" Path="/style/styles.css" />
        <telerik:StyleSheetReference IsCommonCss="False" Path="/RadControls/Menu/Skins/Default/Menu.Default.css" />
        <telerik:StyleSheetReference IsCommonCss="False" Path="/RadControls/Grid/Skins/ShopIngenix/Grid.ShopIngenix.css" />
        <telerik:StyleSheetReference IsCommonCss="False" Path="/RadControls/Grid/Skins/PriceList/Grid.PriceList.css" />
    </StyleSheets>
</telerik:RadStyleSheetManager>


When I run the project I get the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
 
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
 
Stack Trace:
 
 
[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.UI.ScriptEntrySlot.GetSerializedAssemblyInfo(ScriptEntry scriptEntry) +208
   Telerik.Web.UI.ScriptEntrySlot.SerializeScriptEntry(ScriptEntry scriptEntry) +71
   Telerik.Web.UI.ScriptEntryUrlBuilder.TryAddScriptEntry(ScriptEntry scriptEntry) +56
   Telerik.Web.UI.ScriptEntryUrlBuilder.RegisterScriptEntry(ScriptEntry scriptEntry) +237
   Telerik.Web.UI.RadStyleSheetManager.Page_PreRenderComplete(Object sender, EventArgs e) +258
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8701886
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029


All the css files exist, and are valid. I am not sure where to even begin. I checked my web.config and I have the httpHandlers:
    <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
        <add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false"/>
        <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false"/>
        <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/>
        <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false"/>
  <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" verb="*" validate="false" />
</httpHandlers>
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="URLRewriter" type="URLRewriter.ModuleRewriter, URLRewriter"/>
        <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule"/>
        <add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
    </httpModules>
</system.web>


Ideas?
Ashok
Top achievements
Rank 1
 answered on 09 Dec 2011
2 answers
554 views
Hi,
I have a Radio button group on my page as part of a form . How do i detect which of the radio buttons has been selected in the server side code.? Is there an easier way than testing each button to see if it is checked?

Chris

 

<telerik:RadButton ID="NordicInclBtn" runat="server" GroupName="NordicsGroup" Checked="true"
  
Skin="Office2010Blue" Text="RadButton" ToggleType="Radio" AutoPostBack="false">
  
<ToggleStates>
  
<telerik:RadButtonToggleState Text="Include" PrimaryIconCssClass="rbToggleRadioChecked" />
  
<telerik:RadButtonToggleState Text="Include" PrimaryIconCssClass="rbToggleRadio" />
  
</ToggleStates>
  
</telerik:RadButton>
  
<telerik:RadButton ID="NordicExcBtn" runat="server" GroupName="NordicsGroup" AutoPostBack="false"
  
Skin="Office2010Blue" Text="RadButton" ToggleType="Radio">
  
<ToggleStates>
  
<telerik:RadButtonToggleState Text="Exclude" PrimaryIconCssClass="rbToggleRadioChecked" />
  
<telerik:RadButtonToggleState Text="Exclude" PrimaryIconCssClass="rbToggleRadio" />
  
</ToggleStates>
  
</telerik:RadButton>
  
<telerik:RadButton ID="NordicOnlyBtn" runat="server" GroupName="NordicsGroup" AutoPostBack="false"
  
Skin="Office2010Blue" Text="RadButton" ToggleType="Radio">
  
<ToggleStates>
  
<telerik:RadButtonToggleState Text="Only" PrimaryIconCssClass="rbToggleRadioChecked" />
  
<telerik:RadButtonToggleState Text="Only" PrimaryIconCssClass="rbToggleRadio" />
  
</ToggleStates>
  
</telerik:RadButton>

 

 

 

 

Chris
Top achievements
Rank 1
 answered on 09 Dec 2011
1 answer
55 views
I am trying to add a Required validation to a bound Drop Down Box.  I have code that does this for a text box and it works, but it doesn't work for a Drop Down box.

This Works:

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated


        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then


            Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
            Dim editor As GridTextBoxColumnEditor = DirectCast(item.EditManager.GetColumnEditor("CurrencyTarget_NativeCurrent"), GridTextBoxColumnEditor)
            Dim cell As TableCell = DirectCast(editor.TextBoxControl.Parent, TableCell)
            Dim validator As New CompareValidator ' RequiredFieldValidator()


            editor.TextBoxControl.ID = "NCReqValidator"
            validator.ControlToValidate = editor.TextBoxControl.ID
            validator.Operator = ValidationCompareOperator.GreaterThanEqual
            validator.ValueToCompare = "0"
            validator.ErrorMessage = "* Native Current is a required field"
            cell.Controls.Add(validator)

        End If
End Sub

But when I add the same code for a drop down box, it does not:

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated


        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim item2 As GridEditableItem = TryCast(e.Item, GridEditableItem)
            Dim editor2 As GridDropDownListColumnEditor = DirectCast(item2.EditManager.GetColumnEditor("ddCountryCode"), GridDropDownListColumnEditor)
            Dim cell2 As TableCell = DirectCast(editor2.DropDownListControl.Parent, TableCell)
            Dim validator2 As New CompareValidator ' RequiredFieldValidator()

            editor2.DropDownListControl.ID = "CCReqValidator"
            validator2.ControlToValidate = editor2.DropDownListControl.ID
            validator2.Operator = ValidationCompareOperator.NotEqual
            validator2.ValueToCompare = "XXX"
            validator2.ErrorMessage = "* Country Code is a required field"
            cell2.Controls.Add(validator2)

        End If


    End Sub
Pavlina
Telerik team
 answered on 09 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?