Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
312 views
I have a RadGrid that is populated in the code-behind with a DataTable. The grid has an edit FormTemplate:
<telerik:RadGrid ID="rgFileList" runat="server" OnItemCommand="rgFileList_ItemCommand">
            <MasterTableView HorizontalAlign="Right">
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table style="width: 85%" align="center">
                            <tr>
                                <td style="width: 35%" align="right" >Description:  </td>
                                <td style="width: 65%">
                                    <asp:TextBox ID="txtDescription" runat="server" Text='<%# Bind("description") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr><tdcolspan="2"> </td></tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" />
                                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>

When I click the 'Edit' button on a row, the edit form pops up, I enter the Description textbox, and click the Update button.  Control goes to

rgFileList_ItemCommand where the code is:

protected void rgFileList_ItemCommand(object source, GridCommandEventArgs e)
    {
        string strCommand = e.CommandName.ToUpper().Trim();
 
        if (strCommand == "UPDATE")
        {
            GridEditableItem grdSelected = (GridEditableItem)e.Item;
            string filename = grdSelected.GetDataKeyValue("filename").ToString().Trim();
 
            TextBox tb = (TextBox)grdSelected.FindControl("txtDescription");
            string description = tb.Text.ToString().Trim();


the problem is that the TextBox value is the original value of description for that row, not the new value typed into the textbox.  Why?  Can't figure out why it does not result in the new value.
The GridEditableItem grdSelected object is showing:

EditManager = 'grdSelected.EditManager' threw an exception of type 'Telerik.Web.UI.GridBindingException'GridEditableItem

{"The current EditFormType does not support the requested editing capabilities."}

Dan
Top achievements
Rank 2
 answered on 14 Feb 2012
1 answer
138 views

Hi together,

I have a question about the RadGrid. I have now created a RadGrid with a Edit, Delete and Add new Record Button. The Edit Mask shows fine, but if I Edit a record it dosn't update it. When I debug I see that it doesnt't run my Update Method in my Code.

Below my apsx and my methods.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadioButton1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadioButton2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadioButton2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadioButton1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="CheckBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
        Width="75px" Transparency="25">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadGrid ID="radGrid1" AutoGenerateEditColumn="True" DataSourceID="objectDataSource1"
        runat="server" GridLines="None" Skin="Office2010Blue">
        <MasterTableView AllowAutomaticUpdates="True" AllowAutomaticInserts="True" CommandItemDisplay="Top"
            DataSourceID="ObjectDataSource1">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>
               <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="DeleteColumn">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings ColumnNumber="2" CaptionDataField="Address" CaptionFormatString="Edit properties of Address Case Relations">
                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"/>           
                 <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                <PopUpSettings ScrollBars="None" />
            </EditFormSettings>
             
            <RowIndicatorColumn Visible="False">
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn Resizable="False" Visible="False">
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="objectDataSource1" TypeName="ESTV.A3.Logic.AddressCaseRelationBll" SelectMethod="Select" UpdateMethod="Update" InsertMethod="Insert" DeleteMethod="Delete" runat="server"
        OldValuesParameterFormatString="original_{0}">
        <SelectParameters>
            <asp:QueryStringParameter Name="addressId" Type="String" Direction="Input" QueryStringField="id">
            </asp:QueryStringParameter>
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="id" Type="String" />
            <asp:Parameter Name="NotificationDate" Type="DateTime" />
            <asp:Parameter Name="NoticeOfReceipt" Type="Boolean" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="id" Type="String" />
            <asp:Parameter Name="NotificationDate" Type="DateTime" />
            <asp:Parameter Name="NoticeOfReceipt" Type="Boolean" />
        </InsertParameters>
        <DeleteParameters>
            <asp:Parameter Name="id" Type="String"/>
        </DeleteParameters>
    </asp:ObjectDataSource>

And here my Code

public List<AddressCaseRelation> Select(string addressId)
       {
           ////TODO: validation and error handling
           Guid guidId = new Guid(addressId);
           return entityDao.GetByAddressId(guidId);
       }
 
       public void Update(string id, bool noticeOfReceipt, DateTime notificationDate)
       {
           Guid guidId = new Guid(id);
           AddressCaseRelation addressCaseRelation = entityDao.GetById(guidId);
 
           addressCaseRelation.NoticeOfReceipt = noticeOfReceipt;
           addressCaseRelation.NotificationDate = notificationDate;
            
           entityDao.Update(addressCaseRelation);
           entityDao.CommitChanges();
       }
 
       public void Insert(string id, bool noticeOfReceipt, DateTime notificationDate)
       {
           Guid guidId = new Guid(id);
           AddressCaseRelation addressCaseRelation = entityDao.GetById(guidId);
 
           addressCaseRelation.NoticeOfReceipt = noticeOfReceipt;
           addressCaseRelation.NotificationDate = notificationDate;
 
           entityDao.Update(addressCaseRelation);
           entityDao.CommitChanges();
       }
 
       public void Delete(string id)
       {
           Guid guidId = new Guid(id);
           AddressCaseRelation addressCaseRelation = entityDao.GetById(guidId);
           entityDao.Delete(addressCaseRelation);
           entityDao.CommitChanges();
       }

I have also the same problem if i click the Add new Record Button, the form doesnt appear. What is here wrong?
Regards and thanks


Veli
Telerik team
 answered on 14 Feb 2012
4 answers
1.7K+ views
Hello all, 
  
          I am new to using telerik rad controls and i am really excited now to use them. Can anybody post a sample code on how to attach the tooltip to a label which is the first template column in my radgrid. Hovering over this competencyname should display its corresponding info. Can i get a sample code here.

code

<telerik:GridTemplateColumn>

<ItemTemplate>

<asp:Label ID="lblComp" Text='<% #Eval("CompetencyName") %>' runat="server"></asp:Label>

<!-- POP Up control for displaying competency info -->

<telerik:RadToolTipManager runat="server" ID="RadToolTip3" Height="240px" Width="500px"

TargetControlID="lblComp" IsClientID="true" OffsetY="4" Sticky="true" Animation="Fade"

Position="BottomCenter" RelativeTo="Element" Skin="Telerik" OnAjaxUpdate="OnAjaxUpdate">

</telerik:RadToolTipManager>

<!-- end of pop up control for displaying info -->

</ItemTemplate>

</telerik:GridTemplateColumn>

I have just tried displaying a tooltip with some text but nothing is being displayed.please help i did not understand the sample already provided by telerik.
I am developing dnn modules

Thanks,
Sandeep.M

    
Richard
Top achievements
Rank 1
 answered on 14 Feb 2012
3 answers
178 views
Hi,

I am using Telerik.Web.UI rev 2011.1.315.35. I have met a strange issue — opening the Document Manager and navigating to one specific folder causes Document Mamanger to display the following error message:

There was an error in the callback.
    <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
         </div>
     </div>
 </div></li><li class="rtLI"><div class="rtMid">
     <span class="rtSp"></span><span class="rtPlus"></span><div class="rtIn">
         <div class="rtTemplate">
             <span></span><span></span>
        </div>
...

This happens only with one item in the content tree. Clicking on it results in the mentioned error message displayed, and the subfolders of this folder are not expanded, though they are displayed in the middle pane. Could you please provide me with some assumptions on how to fix this?
Rumen
Telerik team
 answered on 14 Feb 2012
3 answers
251 views
Hi,

I'm hiding some of the column of detail table view in prerender event but the grid is not refreshing .

once I expand and collapse the grid it's refreshing.

 
var hideColumn = DBContext.TankMeasurementTypes.Where(p => p.TankMeasurementType_id == strpID);
 
            foreach (var x in hideColumn)
            {
                if (x.FK_MeasurementId == 2)
                {
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Tot_Volumne").Visible = false;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Est").Visible = true;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Feetperinch").Visible = true;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Increment_Start").Visible = true;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Increment_End").Visible = true;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("StrapLength").Visible = true;
                    grdTakStrap.MasterTableView.DetailTables[0].CommandItemSettings.AddNewRecordText = "Add Strap";
 
                }
                else
                {
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Tot_Volumne").Visible = true;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Est").Visible = false;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Feetperinch").Visible = false;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Increment_Start").Visible = false;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("Increment_End").Visible = false;
                    grdTakStrap.MasterTableView.DetailTables[0].GetColumn("StrapLength").Visible = false;
                    grdTakStrap.MasterTableView.DetailTables[0].CommandItemSettings.AddNewRecordText = "Add BBL/Inch";
                }


please help me for this issue

Regards,
Yasar
Tsvetina
Telerik team
 answered on 14 Feb 2012
1 answer
154 views

We are trying to create lightweight page and we want combine css and javascript to reduce requests.

But we are not using any Ajax on the page. 

Aspx page mark-up: 
  <head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager
      id="StyleSheetManager" 
      runat="server" >   
      <StyleSheets >
        <telerik:StyleSheetReference Path="~/Webforms/UI/Mobile/as.mobile.default.theme.min.css" />
        <telerik:StyleSheetReference Path="~/Webforms/UI/Mobile/jquery.mobile.structure-1.0.1.min.css" />
      </StyleSheets>
    </telerik:RadStyleSheetManager>
  </head>
  <body>
    <form id="form1" runat="server">
      <telerik:RadScriptManager       
        ID="ScriptManager"
        Runat="Server" 
        ClientIDMode="Static"
        EnableScriptCombine="true" 
        OutputCompression="AutoDetect" 
        ScriptMode="Release"
        AjaxFrameworkMode="Disabled"
        EnablePartialRendering="false" 
        CompositeScript-ScriptMode="Release"
        LoadScriptsBeforeUI="false" >
        <CompositeScript>       
          <Scripts>
            <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" />
            <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" />
            <asp:ScriptReference Name="jQuery" />
          </Scripts>
        </CompositeScript>
      </telerik:RadScriptManager>
    </form>
  </body>
</html>


So we set AjaxFrameworkMode="Disabled" and added the additional scripts.  On load the page give the following error on "Sys.Application.add_load(loadHandler); line":  

Uncaught ReferenceError: Sys is not defined 
<script type="text/javascript">
//<![CDATA[
;(function() {
                        function loadHandler() {
                            var hf = $get('StyleSheetManager_TSSM');
                            if (!hf._RSSM_init) { hf._RSSM_init = true; hf.value = ''; }
                            hf.value += ';|634643790138684980:20a54711:5489a487';
                            Sys.Application.remove_load(loadHandler);
                        };
                        Sys.Application.add_load(loadHandler);
                    })();//]]>
</script>


how can we achieve this. 


Thank you

Farid
Simon
Telerik team
 answered on 14 Feb 2012
8 answers
353 views
I have to add a radscriptmanager in a base class and I want to combine the script however it doesn't appear to work. I am ensuring that this control is added as the first control of the form. I have the following...

RadScriptManager sm = new RadScriptManager();
                sm.ScriptMode = ScriptMode.Release;
                ScriptReference telerikCore = new ScriptReference("~/Scripts/Common/Core.js");
                ScriptReference jquery = new ScriptReference("~/Scripts/Common/jQuery.js");
                ScriptReference jQueryPlugins = new ScriptReference("~/Scripts/Common/jQueryPlugins.js");
                ScriptReference navigationScripts = new ScriptReference("~/Scripts/Common/Navigation/NavigationScripts.js");
                ScriptReference radMenuScripts = new ScriptReference("~/Scripts/Menu/RadMenuScripts.js");
                ScriptReference radCalendarCommonScript = new ScriptReference("~/Scripts/Calendar/RadCalendarCommonScript.js");
                ScriptReference radCalendarScript = new ScriptReference("~/Scripts/Calendar/RadCalendarScript.js");
                ScriptReference jqueryValidate = new ScriptReference("~/js/jquery.validate.js");
                ScriptReference slimStatAnalytics = new ScriptReference("~/slimstat/?js");
                sm.Scripts.Add(telerikCore);
                sm.Scripts.Add(jquery);
                sm.Scripts.Add(jQueryPlugins);
                sm.Scripts.Add(navigationScripts);
                sm.Scripts.Add(radMenuScripts);
                sm.Scripts.Add(radCalendarCommonScript);
                sm.Scripts.Add(radCalendarScript);
                sm.Scripts.Add(jqueryValidate);
                sm.Scripts.Add(slimStatAnalytics);

                sm.EnableScriptCombine = true;
                sm.EnablePageMethods = true;
                sm.OutputCompression = OutputCompression.AutoDetect;

                form.Controls.AddAt(0, sm);

I get a Telerik.Web.UI.WebResource.axd file containing 10,000 lines of code which looks like Ms Ajax related js - no reference to Telerik in there at all. My page still contains the scripts as separate links. Do I need to set enableembeddedscripts to false on all my rad controls? How about the RegisterWithScriptManager property on radmenu?

If I create another page and do this in mark up it works fine. What am I doing wrong? I don't suppose you have an example of this working?

Thanks
Matt
Simon
Telerik team
 answered on 14 Feb 2012
1 answer
53 views
Is it possible to show 45 days in the month view. I looked around and it looks like in the Silverlight version we can do it by settong the visibleDateRange property. Is it possible for ASP.Net AJAX version?
Thanks,
Mona
Peter
Telerik team
 answered on 14 Feb 2012
1 answer
159 views
I've noteced, that RadAjaxManager works only in Google Chrome, Mozilla Firefox 7.0.1, but does not work neither in IE9, nor in Safari or may be even more browser.
I'd like to ask, if there is any work around or this control is not designed to support popular browsers. Or is there any mistakes in my code.

I have a Master page, Web user control and Web form page. Here is the code to reproduce bug.

Master page
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="RAM.Site" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc" %>
<!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>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <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>
            <telerik:RadAjaxManager runat="server" ID="RadAjaxManager" onajaxrequest="RadAjaxManager_AjaxRequest">
                <AjaxSettings>
                    <telerik:AjaxSetting>
                    </telerik:AjaxSetting>
                </AjaxSettings>       
            </telerik:RadAjaxManager>
            <asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
                <ContentTemplate>               
                    <uc:WebUserControl ID="WebUserControl1" runat="server" />               
                </ContentTemplate>
            </asp:UpdatePanel>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">       
            </asp:ContentPlaceHolder>
        </div>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
 
                function doAjaxRequest() {
                    $find("<%= RadAjaxManager.ClientID %>").ajaxRequest("AddNumber");
                    var UpdatePanel = '<%= UpdatePanel.ClientID %>';
                    __doPostBack(UpdatePanel, '');
                    return false;
                }
 
            </script>
        </telerik:RadCodeBlock>  
    </form>
</body>
</html>

Master page code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace RAM
{
    public partial class Site : System.Web.UI.MasterPage
    {
        private int _number;
        public int Number
        {
            get
            {
                if (Session["Number"] != null)
                    _number = (int)Session["Number"];
                else _number = 0;
                return _number;
            }
            set
            {
                Session["Number"] = value;
            }
        }
 
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Session["Number"] = Number;           
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
              
        }
 
        protected void RadAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            if (e.Argument.StartsWith("Add"))
            {
                Number++;
            }
        }
    }
}

Web User Control:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl.ascx.cs" Inherits="RAM.WebUserControl" %>
<asp:Label ID="Label" runat="server" Text="---"></asp:Label>

Web User Control code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace RAM
{
    public partial class WebUserControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label.Text = (Page.Master as Site).Number.ToString();
        }
    }
}

Web Form:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm.aspx.cs" Inherits="RAM.WebForm" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Button ID="Button" runat="server" Text="Increase number" OnClientClick="doAjaxRequest(); return false;" />
</asp:Content>


Maria Ilieva
Telerik team
 answered on 14 Feb 2012
3 answers
261 views
Hi,

Here I need to set radmenu fit to screen (browser). Please assist me how can I achieve it? My Menu binding is dynamic from database.

ref. http://demos.telerik.com/aspnet-ajax/menu/examples/functionality/scrolling/defaultcs.aspx

What I have tried (As below):

JavaScript:

<script type="text/javascript">
        function pageLoad() {
            var menu = $find("<%= RadMenu1.ClientID %>");
            debugger;
            var menuWid = getWindowWidth() + "px";
            menu.offsetWidth = menuWid;
            menu._element.offsetParent.clientWidth = menuWid;
            menu._element.offsetParent.scrollWidth = getWindowWidth() - 100 + "px";
            menu.repaint();
        }
        window.onresize = pageLoad;
 
        function getWindowWidth() {
            var windowWidth = 0;
            if (typeof (window.innerWidth) == 'number') {
                windowWidth = window.innerWidth;
            }
            else {
                if (document.documentElement && document.documentElement.clientWidth) {
                    windowWidth = document.documentElement.clientWidth;
                }
                else {
                    if (document.body && document.body.clientWidth) {
                        windowWidth = document.body.clientWidth;
                    }
                }
            }
            return windowWidth;
        }
    </script>

HTML:

<telerik:RadMenu ID="RadMenu1" runat="server" EnableRootItemScroll="true" width="100%"
        EnableRoundedCorners="true">
        <Items>
            <telerik:RadMenuItem Text="Arial" />
            <telerik:RadMenuItem Text="Verdana" />
            <telerik:RadMenuItem Text="Tahoma" />
            <telerik:RadMenuItem Text="Sans-serif" />
            <telerik:RadMenuItem IsSeparator="true" />
            <telerik:RadMenuItem Text="Arial" />
            <telerik:RadMenuItem Text="Arial Black" />
            <telerik:RadMenuItem Text="Arial Narrow" />
            <telerik:RadMenuItem Text="Arial Unicode MS" />
            <telerik:RadMenuItem Text="Bookman Old Style" />
            <telerik:RadMenuItem Text="Bookshelf Symbol 7" />
            <telerik:RadMenuItem Text="Century" />
            <telerik:RadMenuItem Text="Century Gothic" />
            <telerik:RadMenuItem Text="Comic Sans MS" />
            <telerik:RadMenuItem Text="Courier New" />
            <telerik:RadMenuItem Text="Garamond" />
            <telerik:RadMenuItem Text="Georgia" />
            <telerik:RadMenuItem Text="Goudy Old Style" />
            <telerik:RadMenuItem Text="Goudy Stout" />
            <telerik:RadMenuItem Text="Haettenschweiler" />
            <telerik:RadMenuItem Text="Helvetica" />
            <telerik:RadMenuItem Text="Impact" />
            <telerik:RadMenuItem Text="Imprint MT Shadow" />
            <telerik:RadMenuItem Text="Latha" />
            <telerik:RadMenuItem Text="Lucida Console" />
            <telerik:RadMenuItem Text="Lucida Sans" />
            <telerik:RadMenuItem Text="Lucida Sans Typewriter" />
            <telerik:RadMenuItem Text="Lucida Sans Unicode" />
        </Items>
    </telerik:RadMenu>

Thanks & Regards,

Kaushal Jani
Peter
Telerik team
 answered on 14 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?