Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
174 views


Posted 11 minutes ago (permalink)

I have the following aspx code in a usercontrol:

<telerik:RadTabStrip ID="radTSCapabilities" runat="server" SelectedIndex="0" Skin="Default" MultiPageID="radMPCapabilities" />
    <telerik:RadMultiPage ID="radMPCapabilities" runat="server" SelectedIndex="0" />

I dynamically create the Tabs and PageViews from the code behind on load.  Inside the PageView is a RadTreeView.  See code below:
Telerik.Web.UI.RadPageView tmpPageView = new Telerik.Web.UI.RadPageView();
tmpPageView.ID = type.AbilityType.Name;
radMPCapabilities.PageViews.Add(tmpPageView);
 
//Add a Tab for the AbilityType
Telerik.Web.UI.RadTab tmpTab = new Telerik.Web.UI.RadTab(type.AbilityType.Name, type.AbilityType.ID.ToString());
tmpTab.PageViewID = tmpPageView.ID;
radTSCapabilities.Tabs.Add(tmpTab);
 
//Create and Load the Rad Tree
Telerik.Web.UI.RadTreeView radTree = new Telerik.Web.UI.RadTreeView();
radTree.Skin = "Default";
radTree.CheckBoxes = true;
radTree.TriStateCheckBoxes = true;
radTree.CheckChildNodes = true;
radTree.NodeDataBound += new Telerik.Web.UI.RadTreeViewEventHandler(radTree_NodeDataBound);
radTree.ID = type.AbilityType.ID.ToString() + type.AbilityType.Name.Replace(" ""_");
radTree.DataTextField = "Name";
radTree.DataValueField = "ID";
radTree.DataFieldID = "ID";
radTree.DataFieldParentID = "ParentID";
 
//If there are multiple Ability Types in result set then go to the DB to get all Abilities for that type
if (distinctAbilityTypes.Count() != 1)
    radTree.DataSource = AbilityMgr.GetAbilitiesByAbilityTypeID(type.AbilityType.ID);
else
    radTree.DataSource = tmpAbilities;
 
//Bind the Tree
radTree.DataBind();
 
//Add a top border
Literal tmpLiteral = new Literal();
tmpLiteral.Text = "<div style='border-top:solid 1px #AAAAAA;'></div>";
 
//Add the Literal and Tree to the associated PageView
radMPCapabilities.FindControl(type.AbilityType.Name).Controls.Add(tmpLiteral);
radMPCapabilities.FindControl(type.AbilityType.Name).Controls.Add(radTree);

I am trying to get a reference to the dynamically created RadTreeView.  I have been unable to do so for some time now.  Please help.
Chris Salas
Top achievements
Rank 1
 answered on 19 Jan 2012
1 answer
170 views
Hey,

I have a RadSplitter with RadPanes, RadSplitBars, ...
Is it possible to set scroll position of a RadSlidingPane when I'm scrolling an another RadPane?

For exemple, when I click a node in the first RadPane : the same node is clicked in the RadSlidingPane.
When I expand a node in the first RadPane...

But I'd like to have the same rendering when I scroll the first pane and I can't move the content of the RadSlidingPane.

I hope you understand me

Thanks

    Michel
Michel
Top achievements
Rank 1
 answered on 19 Jan 2012
1 answer
135 views
I have a scenario where clicking on a control asynchronously loads other control. I have refereed the thread mentioned in "http://www.telerik.com/community/forums/aspnet-ajax/ajax/radajax-manager-does-not-load-js-files-in-dynamically-loaded-user-control.aspx". Used the application website5 provided in the link. If i add an update panel in the provided sample then the JavaScript is not getting loaded.

Code: Default.aspx
 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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 runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server" enableviewstate="false">
    <div>
        <telerik:RadScriptManager runat="server" ID="ScriptManager1">
        </telerik:RadScriptManager>
        <telerik:RadSplitter ID="RadSplitter1" runat="server" Height="100%" Width="100%">
            <telerik:RadPane ID="LeftPane" runat="server" Width="300px" Scrolling="None" MinWidth="200"
                Height="100%">
                <asp:Button runat="server" ID="Button1" Text="Load Control 1" OnClick="Button1_Click" />
            </telerik:RadPane>
            <telerik:RadSplitBar ID="RadSplitBar2" runat="server" CollapseMode="Forward" />
            <telerik:RadPane ID="MainPane" runat="server" Scrolling="None">
                <telerik:RadSplitter runat="server" Orientation="Horizontal">
                    <telerik:RadPane ID="RadPane2" runat="server" Height="15%" MaxHeight="300">
                        <div class="qsfexHeader">
                            Search Pane
                        </div>
                    </telerik:RadPane>
                    <telerik:RadSplitBar ID="RadSplitBar1" runat="server" CollapseMode="Forward" />
                    <telerik:RadPane ID="RadPane1" runat="server" Scrolling="None">
                        <telerik:RadSplitter ID="RadSplitter3" runat="server" Orientation="Vertical" CssClass="SplitterResultsReading"
                            Width="100%">
                            <telerik:RadPane ID="RadPane3" runat="server" MinWidth="300" Scrolling="None">
                                <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
                                    <ContentTemplate>
                                        <telerik:RadSplitter ID="RadSplitter4" runat="server" Orientation="Horizontal">
                                            <telerik:RadPane runat="server" ID="ResultViewPane" Scrolling="None">
                                                <asp:PlaceHolder runat="server" ID="PlaceHolder1"></asp:PlaceHolder>
                                            </telerik:RadPane>
                                        </telerik:RadSplitter>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="Button1" />
                                    </Triggers>
                                </asp:UpdatePanel>
                            </telerik:RadPane>
                            <telerik:RadSplitBar ID="RadSplitBar4" runat="server" CollapseMode="Backward" />
                            <telerik:RadPane ID="RadPane4" runat="server" Scrolling="Both" MinWidth="300">
                                <asp:Button runat="server" ID="Button2" Text="Load Control 2" OnClick="Button2_Click" />
                            </telerik:RadPane>
                        </telerik:RadSplitter>
                    </telerik:RadPane>
                </telerik:RadSplitter>
            </telerik:RadPane>
        </telerik:RadSplitter>
    </div>
    </form>
</body>
</html>
Default.aspx.cs

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack && ViewState["LastLoadedControl"] != null)
        {
            string controlName = (string) ViewState["LastLoadedControl"];
            Control control = PlaceHolder1.FindControl(controlName);
            if (control != null)
            {
                PlaceHolder1.Controls.Remove(control);
            }

            control = LoadControl(string.Format("~/{0}.ascx", controlName));
            control.ID = controlName;
            PlaceHolder1.Controls.Add(control);
        }
    }

   

    protected void Button1_Click(object sender, EventArgs e)
    {
        Load();
     //   ViewState["LastLoadedControl"] = "WebUserControl";
    }

    private void Load()
    {
        Control control = LoadControl("~/WebUserControl.ascx");
        control.ID = "WebUserControl";
        PlaceHolder1.Controls.Clear();
        PlaceHolder1.Controls.Add(control);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Control control = LoadControl("~/WebUserControl.ascx");
        control.ID = "WebUserControl";
        PlaceHolder1.Controls.Clear();
        PlaceHolder1.Controls.Add(control);
    }

}

Webusercontrol.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
    <script type="text/javascript">
        function pageLoad() {
            alert('Hello from user control <%=ID %>');
        }

        function sayHello()
        {
            alert('Hello again!');
            alert("<%=Button1.ClientID %>");
        }

        function Sample(sender, args) {

            alert("grid created");
        }
               
    </script>    

</telerik:RadScriptBlock>

<asp:Label runat="server" ID="Label1"/>
<asp:Button runat="server" ID="Button1" OnClientClick="sayHello()" Text="Click ME"/>
<telerik:RadGrid ID="RadGrid1" runat="server"  AutoGenerateColumns="true">
 <ClientSettings EnableAlternatingItems="false" EnableRowHoverStyle="True">
                <ClientEvents OnGridCreated="Sample" />
                </ClientSettings>
</telerik:RadGrid>
<div id="panel">
</div>

On clicking of button 1 i am getting JavaScript error "Sample is undefined" .

Jayesh Goyani
Top achievements
Rank 2
 answered on 19 Jan 2012
2 answers
484 views
Hi,
 I have a radgrid with some image column and other data columns with following configuration.
  static headers, column resizing and clip cell content on resize.

I have set image columns width in code behind in pixels and resizable=false. But when I resize other data columns image column also resizes. I don't want them to get resized. 
 
regards,
Mahesh
Rashmi
Top achievements
Rank 1
 answered on 19 Jan 2012
6 answers
134 views
I have a simple search page that contains a a RadComboBox and some text boxes.  When the user submits the form it displays results on a new page for the user.  When the user hits the browser's back button in IE, the user values in the text boxes and combo box are selected.  When I try the same thing in Firefox or Chrome, only the contents of the text boxes are displayed and the combo box reverts to its original value.

I have tried with versions 2008.1.619.20, 2009.1.527.20 and 2010.3.1317.20, but get the same results.

Any thoughts?  Is this the expected result for Firefox and Chrome?

Thanks!

Hans Gunnar
Top achievements
Rank 1
 answered on 19 Jan 2012
1 answer
123 views
Hi,

I want to calculate total of Quantity column (In Edit Mode) using javascript when I am using group by functionality in Rad Grid. I can do Grand total using javascript but not able to do group by total using javascript as I don't know how to check which group is being edited.

For grand total I am passing Footer value in Java script and deducting it from current value.

Thanks,
Mona

Tsvetina
Telerik team
 answered on 19 Jan 2012
3 answers
170 views
Hi,

I have two questions on the drop down menu. First one should be easier, do you have an EnableAutoScroll as in the RadMenu? I have a drop down that can go beyond the window limits and it would be very useful to have the scroll as there is in the menu.

The second one is a bit more complicated. My drop down is constructed on the client side, and it is based on adding items. However, I noticed that whenever I add first a short text item then a long text item, the long text gets wrapped into two lines or cutoff if I use nowrap. Is there a way to adjust the width of the drop down menu to fit all item texts?

Thanks,
Eduardo
Peter
Telerik team
 answered on 19 Jan 2012
5 answers
697 views
I am building a DataTable dynamically at run time and I am also using templates in the Cells that again are dynamically loaded.
The template is currently extremely simple in that it consists solely a CheckBos and a HiddenField like so:
<asp:CheckBox ID="cb" runat="server" /> <asp:HiddenField ID="hf" runat="server" />

I trap the ItemDataBound Event of the Grid and have code similar to that below:
if (e.Item is GridDataItem)
{
    GridDataItem item = (GridDataItem)e.Item;
    DataRowView drv = (DataRowView)item.DataItem;
    for (int i = 0; i < rgTags.MasterTableView.Columns.Count; i++ )
    {
        string uniqueName = rgTags.MasterTableView.Columns[i].UniqueName;
        if (drv[i] is System.DBNull)
        {
            item[uniqueName].Controls[0].FindControl("cb").Visible = false;
        }
        else
        {
            AdminTag tag = (AdminTag)drv[i];
            ((CheckBox)item[uniqueName].Controls[0].FindControl("cb")).Text = tag.sText;
            ((HiddenField)item[uniqueName].Controls[0].FindControl("hf")).Value = tag.nTagId.ToString();
        }
    }
}

My question is why do I have to have the Controls[0]. before the FindControl() calls? I don't like hard coding things like that and would prefer a more elegant way to find the control in the template.

It is wo0rking now, but it's inelegant and it took me a long time to figure it out and I am sure it will get broken b y a future release.

Martin
Tsvetina
Telerik team
 answered on 19 Jan 2012
1 answer
28 views
The RadMenu control has the Target Property, How do I set this property when binding the menu to a SiteMapDataSource?
Peter
Telerik team
 answered on 19 Jan 2012
4 answers
367 views
Hi All,

i am using a RadMenu on my page and i am handling its click event from server side...

when i click on of the item i open another page in rad window ...

all is ok and the window is opened successfully.... i do what i need there and close it...

BUT

i noticed when i refresh the page that holds the radmenu, the click event is called again and the RadWindow is opened again!!!

how can i avoid this from happening!!!

Best Regards
Asa'ad
Kate
Telerik team
 answered on 19 Jan 2012
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?