Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
571 views
I used some code found on this forum to implement checkboxes in a combobox itemtemplate. everything works fine apart from i want the saved items checkbox to be checked when the dropdown is viewed.
any ideas?

here is the front end

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TopFiveArticlesSelector.ascx.cs" Inherits="CMSFormControls_TopFiveArticlesSelector" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 <script type="text/javascript">
            var hiddenfld = ("<%= this.Hidden.ClientID %>");
            var cancelDropDownClosing = false;
             
            function StopPropagation(e)
            {
                //cancel bubbling
                e.cancelBubble = true;
                if (e.stopPropagation)
                {
                    e.stopPropagation();
                }
            }
 
            function onDropDownClosing()
            {
                cancelDropDownClosing = false;
            }
 
            function onCheckBoxClick(chk)
            {
                var combo = $find("<%= RadComboBox2.ClientID %>");
                //holds the text of all checked items
                var text = "";
                //holds the values of all checked items
                var values = "";
                //get the collection of all items
                var items = combo.get_items();
                //enumerate all items
                for (var i = 0; i < items.get_count(); i++)
                {
                    var item = items.getItem(i);
                    //get the checkbox element of the current item
                    var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
                    if (chk1.checked)
                    {
                        text += item.get_text() + ",";
                        values += item.get_value() + ",";
                        //alert(item.get_value());
                    }
                }
                //remove the last comma from the string
                text = removeLastComma(text);
                values = removeLastComma(values);
                 
             
                if (text.length > 0)
                {
                    //set the text of the combobox                   
                    combo.set_text(text);
                    document.getElementById(hiddenfld).value = values;                  
                   
                }
                else
                {
                    //all checkboxes are unchecked
                    //so reset the controls
                    combo.set_text("");              
                }
            }
 
            //this method removes the ending comma from a string
            function removeLastComma(str)
            {
                return str.replace(/,$/,"");
            }
 
</script>
<asp:HiddenField ID="Hidden" runat="server"/>
 <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="400" AllowCustomText="true" DataValueField="DocumentID" DataTextField="Title" EmptyMessage="Select upto 5 articles" OnClientDropDownClosed="onDropDownClosing" >
    <ItemTemplate>
        <div onclick="StopPropagation(event)" class="combo-item-template">
            <asp:CheckBox runat="server" ID="chk1" Text='<%#Eval("Title")%>' onclick="onCheckBoxClick(this)" />           
        </div>
    </ItemTemplate>
</telerik:RadComboBox>

here is the backend

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using CMS.SiteProvider;
using CMS.CMSHelper;
using CMS.GlobalHelper;
using Telerik.Web.UI;
 
public partial class CMSFormControls_TopFiveArticlesSelector : CMS.FormControls.FormEngineUserControl
{
    private DataTable dt = null;
 
    protected void Page_Load(object sender, EventArgs e)
    {
        ArticleItems();
    }
 
    /// <summary>
    /// Gets or sets field value
    /// </summary>
    public override Object Value
    {
        get
        {
            return Hidden.Value.ToString();           
        }
        set
        {
            // Ensure drop down list options
            ArticleItems();
 
            Hidden.Value = System.Convert.ToString(value);
 
            string[] RelatedID = Hidden.Value.Split(new char[] { ',' });
                       
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int e = 0; e < RelatedID.Length; e++)
                {
                    if (dt.Rows[i]["DocumentId"].ToString() == RelatedID[e].ToString())
                    {
                        RadComboBox2.Text += dt.Rows[i]["Title"].ToString() + ",";
                        CheckBox checkbox = (CheckBox)RadComboBox2.Items[i].FindControl("chk1");
                        checkbox.Checked = true;
                    }
                }
            }
 
        }
    }
 
    /// <summary>
    /// Returns true if some color is selected. If no, it returns false and displays an error message.
    /// </summary>
    public override bool IsValid()
    {
        if (RadComboBox2.Text != "")
        {
            return true;
        }
        else
        {
            // Set form control validation error message
            this.ValidationError = "Please Select Tags For This Article";
            return false;
        }
    }
 
    protected void ArticleItems()
    {
        DataSet ds = TreeHelper.SelectNodes("/%", false, "CriticalCare.Conclusion;CriticalCare.Literature;CriticalCare.Theory", "", " ", -1, false);
        dt = new DataTable();
 
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            for (int i = 0; i < ds.Tables.Count; i++)
            {
                dt.Merge(ds.Tables[i]);
            }          
            RadComboBox2.DataSource = dt;
            RadComboBox2.DataBind();
 
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CheckBox checkbox = (CheckBox)RadComboBox2.Items[i].FindControl("chk1");
                checkbox.ToolTip = dt.Rows[i]["DocumentID"].ToString();
            }
        }     
    }
}
Simon
Telerik team
 answered on 04 Sep 2010
0 answers
152 views
I bind the schedular with objectdatasource...inseting and update with that datasource only......when i edit the 0ccurence it works and when i edit with series it getting some error like object reference is not set to be istance of class ..i think  some value is not passing... i written
like this
below
 <telerik:RadScheduler ID="RadScheduler1" runat="server" Skin="Web20" DataSourceID="ods_calender"
         DataKeyField="calendartaskid" DataSubjectField="description" DataStartField="startdate"
        DataEndField="enddate" DataRecurrenceField="recurrencerule" DataRecurrenceParentKeyField="recurrenceruleid"
        OnAppointmentDelete="RadScheduler1_AppointmentDelete" OnAppointmentClick="RadScheduler1_AppointmentClick"
        OnOccurrenceDelete="RadScheduler1_OccurrenceDelete">
     
    </telerik:RadScheduler>
    <asp:ObjectDataSource ID="ods_calender" runat="server" InsertMethod="insertUpdate_Calendertasks"
        SelectMethod="Get_Calendertasks" TypeName="General" UpdateMethod="insertUpdate_Calendertasks"
        DeleteMethod="insertUpdate_Calendertasks">
        <%-- <DeleteParameters>
            <asp:Parameter Name="calendartaskid" Type="Int32" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="startdate" Type="DateTime" />
            <asp:Parameter Name="enddate" Type="DateTime" />
            <asp:Parameter Name="recurrencerule" Type="String" />
            <asp:Parameter Name="recurrenceruleid" Type="Int32" />
            <asp:Parameter Name="Recordtype" Type="String" />
            <asp:SessionParameter Name="doneby" Type="Int32" SessionField="UserID" />
            <asp:Parameter Name="cmd" Type="String" DefaultValue="D" />
        </DeleteParameters>--%>
        <UpdateParameters>
           <%-- <asp:ControlParameter ControlID="hdn_appid" Type="Int32" Name="calendartaskid" />--%>
            <asp:Parameter Name="calendartaskid" Type="Int32" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="startdate" Type="DateTime" />
            <asp:Parameter Name="enddate" Type="DateTime" />
            <asp:Parameter Name="recurrencerule" Type="String" />
            <asp:Parameter Name="recurrenceruleid" Type="Int32" />
            <asp:Parameter Name="Recordtype" Type="String" DefaultValue="C" />
            <asp:SessionParameter Name="doneby" Type="Int32" SessionField="UserID" />
            <asp:Parameter Name="cmd" Type="String" DefaultValue="M" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="calendartaskid" Type="Int32" DefaultValue="0" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="startdate" Type="DateTime" />
            <asp:Parameter Name="enddate" Type="DateTime" />
            <asp:Parameter Name="recurrencerule" Type="String" />
            <asp:Parameter Name="recurrenceruleid" Type="Int32" />
            <asp:Parameter Name="Recordtype" Type="String" DefaultValue="C" />
            <asp:SessionParameter Name="doneby" Type="Int32" SessionField="UserID" />
            <asp:Parameter Name="cmd" Type="String" DefaultValue="C" />
        </InsertParameters>
    </asp:ObjectDataSource>



no coding part only source  can u rectify the  error
pich cock
Top achievements
Rank 1
 asked on 04 Sep 2010
0 answers
94 views
Hi,



I am facing this problem i catching dropdown selected value through javascript on on click event of button

Microsoft JScript runtime error: Object doesn't support this property or method

how to solve this problem.
<asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
   
      <telerik:RadComboBox ID="RadComboBox1" runat="server"
                      HighlightTemplatedItems="true"  >
                     <Items>
            <telerik:RadComboBoxItem runat="server" Text="Jan" Value="1" />
            <telerik:RadComboBoxItem runat="server" Text="feb" Value="2" />
            <telerik:RadComboBoxItem runat="server" Text="Mar" Value="3" />
            <telerik:RadComboBoxItem runat="server" Text="Apr" Value="4" />
            <telerik:RadComboBoxItem runat="server" Text="May" Value="5" />
            <telerik:RadComboBoxItem runat="server" Text="June" Value="6" />
            <telerik:RadComboBoxItem runat="server" Text="July" Value="7" />
            <telerik:RadComboBoxItem runat="server" Text="Aug" Value="8" />
            <telerik:RadComboBoxItem runat="server" Text="Sep" Value="9" />
            <telerik:RadComboBoxItem runat="server" Text="Oct" Value="10" />
            <telerik:RadComboBoxItem runat="server" Text="Nov" Value="11" />
            <telerik:RadComboBoxItem runat="server" Text="Dec" Value="12" />
        </Items>
        </telerik:RadComboBox>
    
    
    <input id="Button1" type="button" value="button" onclick="getvalue();" />
     
     
     <script type="text/javascript" language="javascript"> 
function getvalue() 
{ 
  var combo = <%=RadComboBox1.ClientID %>; 
    var val= combo.GetValue(); // getting the selected value 
    var text= combo.GetText();  // getting the selected text 
}


thanks and regards 

shanker.B
shanker bangari
Top achievements
Rank 1
 asked on 04 Sep 2010
1 answer
137 views
Hello people from Telerik world!

This is my first steps with this amazing tool and I'm so impressed with its power, flexibility and documentation...
I've been learning ASP.NET and C# since 6 months ago...

I'm working in a draft based in 'http://demos.telerik.com/webmail/' for an Outlook-like application and the customer wants a combo to choose what skin he wants to see and for this, I was using this example.

I'm facing another problem: In this application, I have another HTML elements like headers (using divs), titles (using h1, divs and spans) that makes part of the visual identity of the application, but when I change the skin, for example, I would like that the header and titles, uses the same color from the current skin.

How can I do that?

I thought in create classes like .Header_Windows7, .Header_Black, .Header_Vista and so on in an external stylesheet used in the application, but how I should apply this for a div, for example?

Exists something like the following?

<div id="header" class="Header_<%= ??? %>">

Thanks,

Marcel
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
 answered on 04 Sep 2010
5 answers
168 views
Hello,

I could use a little assistance here. I have a grid that I'm using popup edit forms to add new records and edit existing ones. On the popup edit form, I have 2 RadTextBoxes that I want to use a JQuery script for to count the characters entered and show the remaining available.

So...I need a way to fire off a client side event and get the client ID of those two RadTextBoxes so I can put them in the JQuery.

The JQuery script is a simple one liner that uses the client ID of the textbox to get the object and then writes the results using a span ID.

Is there a way to use the OnPopUpShowing client side event to get the client ID of those RadTextBoxes? Do I have to do it in the ItemCreated event on the server side and register the JavaScript?

Any help you can provide is much appreciated. Thanks.
Philip Senechal
Top achievements
Rank 1
 answered on 03 Sep 2010
34 answers
738 views
I understand that IE8 is still beta, but wondering if you guys are testing against it yet.  I have placed a combobox on a form and bound it to a simple list.  View this page in IE8 Compatibility Mode and everything looks great - normal sized box.  However, if I turn off compatibility mode the combo stretches to the full width of the window.  It stretches regardless of any width I may have specified directly on the control.

Is this a bug with IE8 or with the controls?

BTW, looks fine in other browsers I have tested, but eventually MS will push IE8 out the door and want to be ready for it.
JULIAN GOMEZ
Top achievements
Rank 1
 answered on 03 Sep 2010
1 answer
125 views

Hello!

I am using a trial version of their software and I'm working with the component RadScheduler and I have the following problem.

When I add an appointment, I need to "start time" and "end time" appear in 24 hour format. Is this possible?

Saul
Top achievements
Rank 1
 answered on 03 Sep 2010
3 answers
134 views
It's been a long road but I've been able to manipulate most of the controls on the AdvancedForm, but now I would either like to make one of the RadTextBox have a button and have it act like a hyperlink and redirect to another form or add a hyperlink control to the AdvancedForm.  I tried

 

Dim txtActTickID As Telerik.Web.UI.RadTextBox = DirectCast(e.Container.FindControl("AttrAction Ticket"), Telerik.Web.UI.RadTextBox)
txtActTickID.ReadOnly = True
txtActTickID.BackColor = Drawing.Color.LightGray
txtActTickID.ShowButton = True
txtActTickID.ClientEvents.OnButtonClick = "ShowAT(" & txtActTickID.Text & ")"
That was executing every time I tried to edit an appointment.  I also tried
Dim objHL As New HyperLink
objHL.NavigateUrl = "TestForm.aspx"
objHL.Text = "Show Test Form"
e.Container.Controls.Add(objHL)
but the control never showed up?  Any ideas?
Veronica
Telerik team
 answered on 03 Sep 2010
3 answers
126 views
I have a radajaxloading panel as followed:

 

<td runat="server" style="padding-bottom:15px; width:40px;">

 

 

 

<asp:Panel ID="pnlHolder" runat="server" Visible="true" ></asp:Panel>

 

 

 

 

<telerik:RadAjaxLoadingPanel id="LoadingPanel1" runat="server" Width="30px"

 

 

Height="30px" IsSticky="false" >

 

 

 

<asp:Image id="Image2" runat="server" ImageUrl="~/Image/ajax-loader.gif" />

 

 

 

</telerik:RadAjaxLoadingPanel>

 

 

 

</td>

 


I have a click event that fires a javascript as followed based on a click event:

<

 

script type="text/javascript" language="javascript">

 

 

var currentLoadingPanel = null;

 

 

var currentUpdatedControl = null;

 

 

 

function AjaxRequestStart() {

 

 

 

if (document.getElementById("<%= hdnAvailabilityChecker.ClientID %>").value == 1) {

 

 

return;

 

}

 

 

if (document.getElementById("<%= TextBox7.ClientID %>").value == "") {

 

 

return;

 

}

 

 

document.getElementById(

"<%= TextBox7.ClientID %>").value = document.getElementById("<%= TextBox7.ClientID %>").value.toUpperCase();

 

 

currentLoadingPanel = $find(

"<%= LoadingPanel1.ClientID %>");

 

 

currentUpdatedControl =

"<%=pnlHolder.ClientID %>";

 

 

currentLoadingPanel.show(currentUpdatedControl);

 

var t = setTimeout("AjaxResponseEnd()", 2000);

 

}

 

 

function AjaxResponseEnd() {

 

 

if (currentLoadingPanel != null) {

 

currentLoadingPanel.hide(currentUpdatedControl);

document.getElementById(

"<%= hdnAvailabilityChecker.ClientID %>").value = 1;

 

 

}

 

 

}


The script works fine when we click the button for the first time. But on the second click it throws the following message:

Microsoft JScript runtime error: Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ctl00_MainContent_pnlHolderPanel'. If it is being updated dynamically then it must be inside another UpdatePanel.

Any help on this will be appreciated. Thanks.

Pavlina
Telerik team
 answered on 03 Sep 2010
5 answers
510 views
Hello,

I have checkbox in the grid and when i try to export to excel it comes out as blank values.
Can you please provide me the solution, It is urgent please.

<telerik:GridCheckBoxColumn DataField="SiHy" HeaderText="SiHy" SortExpression="SiHy" UniqueName="SiHy" AllowFiltering="false"/>
exportOnlyData is set to true; Is there anything else I need to do ?
When I set exportOnlyData to false it exports the real checkbox to excel. I want the values.

Regards,
Parth Patel
Daniel
Telerik team
 answered on 03 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?