Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
76 views
I created a RadControlsWebSite from Visual Studio. 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 
<head runat="server">
    <title></title>
    <link href="Styles/StyleSheet1.css" type="text/css" rel="Stylesheet"  />
            
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    <script type="text/javascript">
        function ensureSomethingSelected(source, eventargs) {
            var dropDown = $find("<%=rcb1.ClientID %>");
 
            if (dropDown.get_text() != null && dropDown.get_text() != dropDown.get_emptyMessage()) {
                args.IsValid = true;
            }
        }
     
    </script>
</head>
 
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <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>
     
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
     
    </telerik:RadAjaxManager>
 
 
 
<div id="cont1">
 
    <h1>SouthWinds Mfg.</h1>
    <div style="overflow:auto;">
        <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
    </div>
    <hr />
    <div id="navButtons">
 
        <div style="float:left; width:100px;">
            <asp:Button ID="btnBack" runat="server" Text="Back" CausesValidation="false"  OnClick="btnBack_Click"/>
        </div>
 
        <div style="float:right;width:100px;">
            <asp:Button ID="btnForward" runat="server" Text="Forward" CausesValidation="false" OnClick="btnForward_Click" />
        </div>
 
    </div>
    <hr />
    <div class="class1">
        <asp:Label ID="Label1" runat="server" Text="ID" CssClass="formLabels"></asp:Label>
        <asp:Label ID="lblID" runat="server"></asp:Label>
    </div>
    <div class="class1">
    <asp:Label ID="Label2" runat="server" AssociatedControlID="txt2" Text="MFG NO" CssClass="formLabels"></asp:Label>
        <asp:TextBox ID="txt2" runat="server"></asp:TextBox>
    </div>
    <div class="class1">
    <asp:Label ID="Label3" runat="server" AssociatedControlID="txt3" Text="PART NO" CssClass="formLabels"></asp:Label>        <asp:TextBox ID="txt3" runat="server"></asp:TextBox>
    </div>
    <div class="class1">
        <asp:Label ID="Label4" runat="server" AssociatedControlID="txt4" Text="DESCR" CssClass="formLabels"></asp:Label>
     <asp:TextBox ID="txt4" runat="server"></asp:TextBox>
    </div>
    <div class="class1">If you do not see your parent, please type it in:</div>
 
    <div id="cont0">
    <telerik:RadAjaxPanel ID="rap1" runat="server">
        <telerik:RadComboBox ID="rcb1" runat="server"                
                ClientIDMode="Static"
                EnableLoadOnDemand="true"
                EnableVirtualScrolling="true"               
                ShowMoreResultsBox="true"
                OnItemsRequested="rcb1_ItemsRequested"
                Width="200" >                   
        </telerik:RadComboBox>
    </telerik:RadAjaxPanel>
    </div>
    <div style="float:none;">
        <asp:CustomValidator ID="cv1" runat="server"
            ValidateEmptyText="true"           
            ControlToValidate="rcb1"     
            EnableClientScript="true"     
            ClientValidationFunction="ensureSomethingSelected"
            ErrorMessage="You must select an item!"
            OnServerValidate="rcb1_ServerValidate">           
    </asp:CustomValidator>   
    </div>       
     <div class="buttonBar">
        <asp:Button ID="btn1" runat="server" Text="Save" OnClick="btn1_Click" />
    </form>
</body>
</html>

Here is my code-behind
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
 
    private const int ItemsPerRequest = 10;
 
    protected void Page_Init(object sender, EventArgs e)
    {
        
    }
     
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadPart();
        }
 
        //***RESET INFORMATION MESSAGES
        lblMessage.Text = "";
 
    }
 
    protected void btn1_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
             
        }
 
    }
 
    protected void  LoadPart()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["widConn"].ToString());
        SqlCommand cmd = new SqlCommand("SELECT * FROM PARTS", con);
 
        DataSet ds = new DataSet("dsParts");
 
        DataTable dt = new DataTable("dtParts");
 
        SqlDataAdapter da = new SqlDataAdapter(cmd);
 
        int currIndex = 0;
        ViewState["currIndex"] = currIndex;
 
        using (con)
        {
            con.Open();
 
            da.Fill(ds);
            dt = ds.Tables[0];
 
            ViewState["dtParts"] = dt;
            ViewState["rowCount"] = dt.Rows.Count;
 
            lblID.Text = Convert.ToString(dt.Rows[currIndex][0]);
            txt2.Text = (string)dt.Rows[currIndex][1];
            txt3.Text = (string)dt.Rows[currIndex][2];
            txt4.Text = Convert.ToString(dt.Rows[currIndex][3]);
        }
         
    }
 
    protected void rcb1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        
    }
 
    protected void rcb1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        DataTable data = GetData(e.Text);
 
        int itemOffset = e.NumberOfItems;
        int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
        e.EndOfItems = endOffset == data.Rows.Count;
 
        for (int i = itemOffset; i < endOffset; i++)
        {
            rcb1.Items.Add(new RadComboBoxItem(data.Rows[i]["FULLY_QUALIFIED_PART_NO"].ToString(), data.Rows[i]["ID"].ToString()));
        }
 
        e.Message = GetStatusMessage(endOffset, data.Rows.Count);
    }
 
 
    private static DataTable GetData(string text)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["widConn"].ConnectionString);
 
        SqlDataAdapter adapter = new SqlDataAdapter("usp_GetMfgPartsScrolling", con);
        adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
 
        adapter.SelectCommand.Parameters.AddWithValue("@text", text);
 
        DataTable data = new DataTable();
 
        using (con)
        {
            con.Open();
            adapter.Fill(data);
        }
         
 
        return data;
    }
 
    private static string GetStatusMessage(int offset, int total)
    {
        if (total <= 0)
            return "No matches";
 
        return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
    }
 
 
    protected void btnForward_Click(object sender, EventArgs e)
    {
        DataTable dt = (DataTable)ViewState["dtParts"];
 
        int currIndex = (Int32)ViewState["currIndex"];
        int rowCount = (Int32)ViewState["rowCount"];
 
        if ((currIndex  + 1) < rowCount)
        {
            lblID.Text = Convert.ToString(dt.Rows[currIndex + 1][0]);
            txt2.Text = (string)dt.Rows[currIndex + 1][1];
            txt3.Text = (string)dt.Rows[currIndex + 1][2];
 
            ViewState["currIndex"] = currIndex + 1;
        }
        else
        {
            lblMessage.Text = "You are at the end of the recordset";
        }
    }
 
    protected void btnBack_Click(object sender, EventArgs e)
    {
        DataTable dt = (DataTable)ViewState["dtParts"];
 
        int currIndex = (Int32)ViewState["currIndex"];       
 
        if (currIndex - 1 >=  0)
        {
            lblID.Text = Convert.ToString(dt.Rows[currIndex - 1][0]);
            txt2.Text = (string)dt.Rows[currIndex - 1][1];
            txt3.Text = (string)dt.Rows[currIndex - 1][2];
 
            ViewState["currIndex"] = currIndex - 1;
        }
        else
        {
            lblMessage.Text = "You are at the beginning of the recordset";
        }
    }
 
 
 
   
 
 
 
 
 
}
I get the following error message
Server Error in '/RadControlsWebSite1' Application.
--------------------------------------------------------------------------------


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). 
Ivana
Telerik team
 answered on 05 Dec 2011
1 answer
86 views
I'm trying to set the End Date when the Start Date is changed on a custom Advanced Form using a Web Service. I've used the following code on an advanced form with a linq data source and it works fine. 
<telerik:RadDatePicker runat="server" ID="StartDate" Width="100px" MinDate="1960-01-01">
    <ClientEvents OnDateSelected="StartDateSelected" />
    <Calendar ID="Calendar1" RangeMinDate="1960-01-01" runat="server"/>
</telerik:RadDatePicker>                           
 
<telerik:RadDatePicker runat="server" ID="EndDate" Width="100px" MinDate="1960-01-01">
    <Calendar ID="Calendar2" RangeMinDate="1960-01-01" runat="server" />
</telerik:RadDatePicker>                           

Javascript Function:

function StartDateSelected(sender, eventArgs) {
    var $ = $telerik.$;
    var endDatejQueryObject = $("[id$='Form_EndDate']");
    var endDatePicker = $find(endDatejQueryObject.attr("id"));
    var newDate = new Date(eventArgs.get_newValue());
    endDatePicker.set_selectedDate(newDate);
}

Using the Chrome debugger, I can see the event triggered when I change the start date. The endDatePicker is found ok and it looks like the end date is set ok via set_selectedDate(newDate), but the end data input box never changes. 

I've tried putting a button on the form and setting the date with an onclick event, it doesn't work. I can set the value of an input control and an asp:textbox, but if I try to set the value on a RadTextBox it doesn't work. I can't seem to set any "Rad" controls via javascript on the advanced form.

Any help is appreciated, thanks.
Ivana
Telerik team
 answered on 05 Dec 2011
1 answer
341 views
Hi,

Help me to solve this problem.

I have a treeview in that I'am binding the nodes based on demand. When page load, i will load level1 treenodes and when expanding the level1 treenode im loading the level2 nodes using treenode value. And in another case I will bind the treeview when user enters a text from textbox.  Here I want to expand all the parent node of the user entered text. In my code its expanding the node what user entered from textbox and its child nodes. But its not expanding the parent node of what user entered from textbox.

I need treeview like as attached image.

My Control:

<

telerik:RadTreeView ID="RadTreeViewCodeTypes" runat="server" OnNodeExpand="RadTree_OnNodeExpand"

 

Skin="HCPro" EnableEmbeddedSkins="false" Width="245px" OnNodeClick="RadTree_OnNodeClick"

Style="white-space: normal" SingleExpandPath="true" >

 

<DataBindings>

 

<telerik:RadTreeNodeBinding Expanded="false" ExpandMode="ServerSide"/>

 

</DataBindings>

 

</telerik:RadTreeView>
Code behind:

RadTreeViewCodeTypes.DataFieldID = "ID";

RadTreeViewCodeTypes.DataFieldParentID = "ParentCode";
RadTreeViewCodeTypes.DataTextField = "TextCode";

RadTreeViewCodeTypes.DataValueField = "ID";

 RadTreeViewCodeTypes.DataSource = TreeviewList;

RadTreeViewCodeTypes.DataBind();

after this binding

foreach (RadTreeNode node in RadTreeViewCodeTypes.GetAllNodes())

{

 if (node.Value == Session["SearchCode"].ToString())

 { 

if (!node.Expanded)  

{
node.ParentNode.ExpandChildNodes();

node.Selected = true;  

RadTreeNode Node = new RadTreeNode(); 

Node = node.ParentNode;
while (Node.ParentNode != null)

{

 

Node.Expanded = true;

Node = Node.ParentNode;

}

node.Selected = true;

}

}

}

Thanks,
Arunshyam. S

Plamen
Telerik team
 answered on 05 Dec 2011
1 answer
91 views
I am experiencing some behavior I consider strange when using the grid with the settings of HierarchyLoadMode="Client" along with paging.  My highest grid has it's PageSize = 10 and is using a NestedViewTemplate with a grid inside of it.  When I execute the page the markup is automatically loaded with 11 rows of controls for the parent grid and then each of them have a nested table with 11 rows within them.  This would be fine if I had that much data, but in most cases I only have a few rows of data at the parent and a two or three at the child grid level. 

In most of my cases, it is causing the size of my pages to increase from 400kb to 1700kb.

Is it expected to populate all of these extra rows in preparation for client activity?

Best Wishes,
Keith
Tsvetina
Telerik team
 answered on 05 Dec 2011
2 answers
100 views
Hi,
I was able to hide the toolbar for visitors and display the content from a database. But I can't get the scrollbar where the content is larger than the control height..
How can I display the scrollbar?

Thanks,
Kamal
Rumen
Telerik team
 answered on 05 Dec 2011
1 answer
122 views

I am making a Telerik Radgrid with EntityDataSource control as its Datasource.

The current table has a Many-To-Many relationship with a second table. I wanted to show the list of Title (field) of the second table on a repeater inside a GridTemplateColumn.

Is it possible to fill the repeater with the list of object from the second table? If it is, then how?

Thanks a lot.

Tsvetina
Telerik team
 answered on 05 Dec 2011
1 answer
107 views
Hello, I am trying to export to pdf using a radeditor, however, when i open the file with adobe reader i get this message:

"Adobe Reader could not open 'Certificate.pfd' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and was wasn't correctly decoded)"

i am assigning to the radeditor.content the html code:

<h1>
<span class="titulo" id="ctl00_ContentPlaceHolder1_Label1">Aplicaciones por tipo</span>
</h1>
<p>
<span id="ctl00_ContentPlaceHolder1_Label2">Aqu&iacute; encuentra las aplicaciones agrupadas por tipo</span>
</p>

Any suggestions?
this is how my radeditor is defined:
 <telerik:RadEditor ID="redCertificate" runat="server" Width="90%" Height="800px"
                Language="es-ES"
                ContentFilters="PdfExportFilter, DefaultFilters">
                <exportsettings openinnewwindow="true" filename="Certificate">
                <Rtf PageHeader="RadEditor content" />
                <Pdf PageTitle="Sample page title" />
            </exportsettings>
                <content></content>
            </telerik:RadEditor>

thanks in advance
Shinu
Top achievements
Rank 2
 answered on 05 Dec 2011
2 answers
75 views
Hi. I have a weird issue where I am trying to enable an HTML button with JQuery from TabStrip. The button is enabled on Chrome and Firefox but only appears enabled when you mouse off the TabStrip in IE7 (or IE7 standards mode under IE8 & IE9). This is a rather urgent problem that needs resolving. Below is the code I'm using. Thanks.

Daniel
<telerik:RadScriptManager runat="server" ID="RadScriptManager1">
    <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" />
    </Scripts>
</telerik:RadScriptManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
 
    <script type="text/javascript">
        window.$ = $telerik.$;
 
        function OnClientTabSelected(sender, eventArgs) {
            $("#Button1:button").removeAttr("disabled");
        }
         
    </script>
 
</telerik:RadCodeBlock>
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnClientTabSelected="OnClientTabSelected" MultiPageID="RadMultiPage1">
    <Tabs>
        <telerik:RadTab runat="server" Text="Root RadTab1">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Root RadTab2">
        </telerik:RadTab>
        <telerik:RadTab runat="server" Text="Root RadTab3">
        </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server">
    <telerik:RadPageView ID="RadPageView1" runat="server">
        RadPageView1</telerik:RadPageView>
    <telerik:RadPageView ID="RadPageView2" runat="server">
        RadPageView2</telerik:RadPageView>
    <telerik:RadPageView ID="RadPageView3" runat="server">
        RadPageView3</telerik:RadPageView>
</telerik:RadMultiPage><br />
<br />
<input id="Button1" type="button" value="button" disabled="disabled" />


Daniel
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 05 Dec 2011
4 answers
200 views
Hi There,

I am facing an issue and not able to figure out what is happening. Here is the scenario.

I have a
MasterPage->ContentPage->RadGrid
MasterPage->ContentPage->RadWindow

I have enabled drag drop functionality on the RadGrid.
Once an Item is dropped a RadWindow(Modal Popup) opens where the user can select a MSDD (stored in the database).
This Rad Popup window has a user control which also has another RadWindow which opens on click of an image and the user can configure a MSDD on this window.

The problem starts when the 2 Popup is used to save new or delete existing MSDD in subsequent calls.
When I reach to the main page I have code which rebinds the grid which contains the newly added MSDD but for mentioned scenario the RadGrid completely disappears as it cannot find any data for that grid on the AjaxRequest method on the server.

It is really difficult to explain the exact issue so I thought of creating a sample project which could re-create the problem, but I was not successful in that.

I cannot attach the sample project due to file type limitaion on this site.
So I am really not sure if its possible to show what I am trying to achieve.

If required I can paste the code for each page.

Thanks,
Nilesh

Nilesh
Top achievements
Rank 1
 answered on 05 Dec 2011
1 answer
88 views
Hi, I have a RadGrid, created entirely programatically, I need to add the equivalent to

<Telerik:GridTemplateColumn UniqueName="Assigned" HeaderText="Assigned">
                    <ItemTemplate>
                        <Telerik:RadButton ID="rbAssigned" runat="server" ToggleType="CheckBox" ButtonType="ToggleButton"
                            AutoPostBack="false" Skin="Forest" EnableEmbeddedSkins="true" EnableEmbeddedBaseStylesheet="true"
                            OnClientLoad="ButtonLoad" CommandName="Select" OnCheckedChanged="ToggleRowSelection">
                            <ToggleStates>
                                <Telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleCheckboxChecked" Selected="true" />
                                <Telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleCheckbox" />
                            </ToggleStates>
                        </Telerik:RadButton>
                    </ItemTemplate>
                    <ItemStyle Width="50px" />
                </Telerik:GridTemplateColumn>

How can I do this? I didn't find any example
Shinu
Top achievements
Rank 2
 answered on 05 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?