Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
102 views
I am using Telerik 2013.1.220.35.

I have a fairly basic Application Page.

<form runat="server" ID="PageForm">
     
<asp:ScriptManager ID="ScriptManager" runat="server" />
  
<telerik:RadComboBox runat="server" ID="cbSubtype" EmptyMessage="Select a sub-type"
                     DataTextField="Description" DataValueField="Id"
                     AutoPostBack="True"
                     OnSelectedIndexChanged="cbSubtype_SelectedIndexChanged">
    
</telerik:RadComboBox>
 
<telerik:RadGrid ID="rgDocuments" runat="server" AutoGenerateColumns="False"
                 CellSpacing="0" GridLines="None" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True"
                 OnNeedDataSource="rgDocuments_NeedDataSource">
    <MasterTableView DataKeyNames="DocumentText" Name="DocumentMaster">
        <Columns>
            <telerik:GridBoundColumn DataField="Discipline" HeaderText="[Discipline]" UniqueName="Discipline" />
            <telerik:GridHyperLinkColumn DataTextField="DocumentText" HeaderText="[Document]" DataNavigateUrlFields="DocumentUrl" UniqueName="DocumentLink" />
            <telerik:GridBoundColumn DataField="Revision" HeaderText="[Rev]" UniqueName="Revision" />
            <telerik:GridBoundColumn DataField="Date" HeaderText="[Date]" UniqueName="Date" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
 
</form>

Also, the C# part.

public partial class StandardsTypicals : LayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<ListBoxGeneralDisplay> list = new List<ListBoxGeneralDisplay>();
                list.Add(new ListBoxGeneralDisplay() { Description = "", Id = -1 });
                list.Add(new ListBoxGeneralDisplay() { Description = "EG - Std. Specs", Id = 0 });
                list.Add(new ListBoxGeneralDisplay() { Description = "EF - Const. Specs", Id = 1 });
                list.Add(new ListBoxGeneralDisplay() { Description = "DO - Typicals", Id = 2 });
  
                cbSubtype.DataSource = list;
                cbSubtype.DataBind();
            }
        }
  
        protected void cbSubtype_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            rgDocuments.Rebind();
        }
  
        protected void rgDocuments_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            if (cbSubtype.SelectedValue != "-1" && !string.IsNullOrEmpty(cbSubtype.SelectedValue))
            {
                List<RadgridStandardsTypicalsDisplay> displayList = new List<RadgridStandardsTypicalsDisplay>();
                displayList.Add(new RadgridStandardsTypicalsDisplay() { Discipline = "Discipline", Date = new DateTime(2013, 04, 01), DocumentText = "Document Text", DocumentUrl = "http://www.google.com", Revision = "A" + cbSubtype.SelectedValue });
                displayList.Add(new RadgridStandardsTypicalsDisplay() { Discipline = "Discipline", Date = new DateTime(2013, 04, 01), DocumentText = "Document Text", DocumentUrl = "http://www.google.com", Revision = "A" + cbSubtype.SelectedValue });
                displayList.Add(new RadgridStandardsTypicalsDisplay() { Discipline = "Discipline", Date = new DateTime(2013, 04, 01), DocumentText = "Document Text", DocumentUrl = "http://www.google.com", Revision = "A" + cbSubtype.SelectedValue });
                rgDocuments.DataSource = displayList;
            }
            else
            {
                List<RadgridStandardsTypicalsDisplay> displayList = new List<RadgridStandardsTypicalsDisplay>();
                rgDocuments.DataSource = displayList;
            }
        }
    }

Normally, I would expect this to work
(In fact, it works in RenderMode Native).
However, as soon as I try to expand the ComboBox, I get this error.


Line: 1617
Erreur : 'top' a la valeur Null ou n'est pas un objet.
Translate to: 'Top' is null or not an object

I tried to debug it.

b.RadComboBox.prototype._getOffsetParentOffset=function(c){var j=0;
var f=0;
var d=a(c.offsetParent);
if(d.css("position")!="static"){var g=d.offset();
j=g.top; // BREAK HERE.. G is null.
f=g.left;
if(c.offsetParent==document.body){var i=parseInt(d.css("top"),10);
if(!isNaN(i)){j+=i;
}var h=parseInt(d.css("left"),10);
if(!isNaN(h)){f+=h;
}}}var e={top:j,left:f};
return e;
};

I added a comment where it breaks. This problem is fairly bizarre. I'm pretty sure I have everything that is required. The ScriptManager is there and is in a Form tag that is runat="server". I can select an item using the text selection and it works. It just never render the items. The error also trigger if I try to resize the window (after I chose to continue after the debug).

I hope you can guide me on the right path.
Simon
Top achievements
Rank 1
 answered on 11 Apr 2013
3 answers
115 views
Hello.

I am creating a class that wraps around a RadToolBar.  The RadToolBar is dynamically created, with the exception that an empty toolbar is defined in the aspx code (example below).  The class allows me to access buttons and a text box with simple class functions, properties, etc.  Works nicely.

What I am stuck on is that I wish to handle button click events IN this class, allowing the new handlers to be then handled by the user in the .vb server-side code with the "handles" process (example idea, below).  I know that I am on the track to figure this out, but I cannot seem to find the right solution.

So, here is the aspx:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="projects.aspx.vb" Inherits="EPD_WEB_APP.projects" %>
 
<%@ Import Namespace="EPD_WEB_APP" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Charting" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title>Test</title>
</head>
<body style="height: 830px; width: 630px">
    <form id="form1" runat="server">
    <div style="height: 821px; width: 1392px; margin-right: 0px;">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <br />
        <telerik:RadToolBar ID="RadToolBar1" runat="server" Skin="Default"
            AutoPostBack="True">
        </telerik:RadToolBar>
        <br />
        <br />
        <asp:Label ID="txtSearchFieldContents" runat="server" Text="Result:"></asp:Label>
    </div>
    </form>
</body>
</html>

And, here is the toolbar class which wraps around the toolbar:

Public Class tToolBar
 
    Private m_RadToolBar As RadToolBar
    Private m_ThisPage As System.Web.UI.Page
    Private m_Skin As String
    Private m_SearchText As String
 
    Public Sub New(ByVal RadToolBar As RadToolBar)
 
        m_RadToolBar = RadToolBar
        m_ThisPage = HttpContext.Current.Handler
        m_SearchText = ""
        m_Skin = m_RadToolBar.Skin
 
        If Not m_ThisPage.IsPostBack Then
 
            Dim btnAdd As New RadToolBarButton()
            btnAdd.Text = "Add"
            btnAdd.Value = "1"
            btnAdd.ImageUrl = "Images/AddRecord.gif"
            'btnAdd.CheckOnClick = True
            m_RadToolBar.Items.Add(btnAdd)
 
            Dim btnEdit As New RadToolBarButton()
            btnEdit.Text = "Edit"
            btnEdit.Value = "2"
            'btnEdit.CheckOnClick = True
            btnEdit.ImageUrl = "Images/Edit.gif"
            m_RadToolBar.Items.Add(btnEdit)
 
            Dim buttonS1 As New RadToolBarButton()
            buttonS1.IsSeparator = True
            m_RadToolBar.Items.Add(buttonS1)
 
            Dim btnSave As New RadToolBarButton()
            btnSave.Text = "Save"
            btnSave.Value = "3"
            btnSave.ImageUrl = "Images/Save.gif"
            m_RadToolBar.Items.Add(btnSave)
 
            Dim btnCancel As New RadToolBarButton()
            btnCancel.Text = "Cancel"
            btnCancel.Value = "4"
            btnCancel.ImageUrl = "Images/Cancel.gif"
            m_RadToolBar.Items.Add(btnCancel)
 
            Dim btnDelete As New RadToolBarButton()
            btnDelete.Text = "Delete"
            btnDelete.Value = "5"
            btnDelete.ImageUrl = "Images/deletex.gif"
            m_RadToolBar.Items.Add(btnDelete)
 
            Dim buttonS2 As New RadToolBarButton()
            buttonS2.IsSeparator = True
            m_RadToolBar.Items.Add(buttonS2)
 
            Dim ddSearchBy As New RadToolBarSplitButton()
            ddSearchBy.Text = "Search By..."
            ddSearchBy.ToolTip = "Select the type of search."
            Dim btnUPC As New RadToolBarButton()
            btnUPC.ToolTip = "Select the type of search."
            btnUPC.Text = "UPC"
            btnUPC.Value = "UPC"
            Dim btnDesc As New RadToolBarButton()
            btnDesc.ToolTip = "Select the type of search."
            btnDesc.Text = "Description"
            btnDesc.Value = "DESC"
            ddSearchBy.Buttons.Add(btnUPC)
            ddSearchBy.Buttons.Add(btnDesc)
            m_RadToolBar.Items.Add(ddSearchBy)
 
            'Dim splitButton As New RadToolBarSplitButton()
 
            Dim btnSearchByTxt As New RadToolBarButton()
            btnSearchByTxt.Text = "Search for?"
            m_RadToolBar.Items.Add(btnSearchByTxt)
 
            Dim btnSearch As New RadToolBarButton()
            btnSearch.Text = "Search"
            btnSearch.Value = "6"
            btnSearch.ImageUrl = "Images/search.gif"
            m_RadToolBar.Items.Add(btnSearch)
 
            Dim buttonS3 As New RadToolBarButton()
            buttonS3.IsSeparator = True
            m_RadToolBar.Items.Add(buttonS3)
 
            Dim btnFirst As New RadToolBarButton()
            btnFirst.Text = "First"
            btnFirst.Value = "8"
            btnFirst.ImageUrl = "Images/blue-first-16.gif"
            m_RadToolBar.Items.Add(btnFirst)
 
            Dim btnPrev As New RadToolBarButton()
            btnPrev.Text = "Previous"
            btnPrev.Value = "9"
            btnPrev.ImageUrl = "Images/blue-prev-16.gif"
            m_RadToolBar.Items.Add(btnPrev)
 
            Dim btnNext As New RadToolBarButton()
            btnNext.Text = "Next"
            btnNext.Value = "10"
            btnNext.ImageUrl = "Images/blue-next-16.gif"
            m_RadToolBar.Items.Add(btnNext)
 
            Dim btnLast As New RadToolBarButton()
            btnLast.Text = "Last"
            btnLast.Value = "11"
            btnLast.ImageUrl = "Images/blue-last-16.gif"
            m_RadToolBar.Items.Add(btnLast)
 
            Disable()
 
        End If
 
        InstantiateSearch()
 
    End Sub
 
    Public Property Skin() As String
        Get
            Return m_Skin
        End Get
 
        Set(ByVal value As String)
            m_Skin = value
            m_RadToolBar.Skin = m_Skin
        End Set
 
    End Property
 
    Public Property SearchText() As String
 
        Get
            m_SearchText = ""
 
            Dim textItem As RadToolBarItem = m_RadToolBar.FindItemByText("Search for?")
            Dim textBox As TextBox = CType(textItem.FindControl("TextBox"), TextBox)
 
            m_SearchText = textBox.Text
 
            Return m_SearchText
        End Get
 
        Set(ByVal value As String)
            m_SearchText = value
 
            Dim textItem As RadToolBarItem = m_RadToolBar.FindItemByText("Search for?")
            Dim textBox As TextBox = CType(textItem.FindControl("TextBox"), TextBox)
 
            textBox.Text = m_SearchText
        End Set
 
    End Property
 
    Public Sub InstantiateSearch()
 
        Dim searchTemplate As New TextBoxSearchTemplate()
        Dim textSearchItem As RadToolBarItem = m_RadToolBar.FindItemByText("Search for?")
        If TypeOf textSearchItem Is RadToolBarButton Then
            searchTemplate.InstantiateIn(textSearchItem)
        End If
 
        m_RadToolBar.DataBind()
 
    End Sub
 
    Public Sub Disable(Optional ByVal scope As String = "")
 
        If scope = "All" Or scope = "" Then
            m_RadToolBar.Enabled = False
        End If
        ' other options may exist...
 
    End Sub
 
    Public Sub Enable(Optional ByRef scope As String = "")
 
        If scope = "All" Or scope = "" Then
            m_RadToolBar.Enabled = True
        End If
        ' other options may exist...
 
    End Sub
 
    'Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        '----- some way of handling the bar's click, and then inside, which button was clicked, like the "Search" button.
        '----- this needs to be then handled by the user who is using the class with a tToolBar.OnClick something...
    'End Sub
 
    Private Class TextBoxSearchTemplate
        Implements ITemplate
 
        Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
            Dim txtbox1 As New TextBox()
 
            txtbox1.ID = "TextBox"
            txtbox1.Text = ""
            txtbox1.Font.Size = 10
            txtbox1.Font.Bold = False
            AddHandler txtbox1.DataBinding, AddressOf txtbox1_DataBinding
            container.Controls.Add(txtbox1)
        End Sub
 
        Private Sub txtbox1_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
            Dim target As TextBox = DirectCast(sender, TextBox)
            Dim button As RadToolBarButton = DirectCast(target.BindingContainer, RadToolBarButton)
            'Dim buttonText As String = DirectCast(DataBinder.Eval(button, "Text"), String)
            'target.Text = buttonText
            target.Text = ""
            target.ToolTip = "What do you wish to search for?"
        End Sub
    End Class
 
End Class


Finally, here is the server-side code:

Public Class projects
    Inherits System.Web.UI.Page
 
    Private formToolBar As tToolBar
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        formToolBar = New tToolBar(RadToolBar1)
        formToolBar.Enable()
 
        If Not Page.IsPostBack Then
 
            'formToolBar.Skin = "Windows7"
 
        Else
 
 
 
        End If
 
 
    End Sub
 
 
    Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
 
        ' the following just tests whether or not I can access the text from the search textbox.
        formToolBar.Skin = formToolBar.SearchText
        txtSearchFieldContents.Text = "Skin: " & formToolBar.Skin
 
        ' what I need is a way in the CLASS to dispatch (fire) events per button,
        ' so that I can have individual handlers in this VB.NET code.
        ' That way, I don't have to do fancy footwork in the VB.NET, but do all
        ' the dirty work in the CLASS, and just let the user
        ' here deal with the inner button.
 
    End Sub
 
End Class


I am sure that in the CLASS, I handle the ToolBar OnClick event, and then determine WHICH RadButton was clicked, and raise an event, which has a CLASS HANDLER for that event.  I would have that handler written in such a way as the user of the class can then create the handler that "HANDLES" tToolBarExample.OnClick event.  This is my question: how do I do this inside my class?  I seem to be close, but I am stuck trying to figure out the final bit.

Thank you
Tomas
Top achievements
Rank 1
 answered on 11 Apr 2013
1 answer
144 views
I want to make sure someone puts in a Description before they upload a file.  Not like the example where the description is put in after. I can do it with manual upload like:
function startManualUpload() {
    var tb = $find('<%=tbFileDesc.ClientID%>');
    var tbtxt = tb._text.length;
    if (tbtxt == 0) {
 //write some error
    }
    else {
        var upload = $find('<%=radUpAssoc.ClientID%>');
        upload.startUpload();
    }
 
}

But then I want to add the description to my AsyncUploadConfiguration.  I'm setting this on the server side though.
How can I add on to my AsyncUploadConfiguration from here?  I'm not so good at javascript so maybe this is easy.

I guess I could do a Response.write with the startmanualUpload function, but that was acting a bit strange.
Hristo Valyavicharski
Telerik team
 answered on 11 Apr 2013
3 answers
178 views

I have an existing app (written by a previous developer) that is calling a stored procedure that populates a RadGrid control. It populates fine the first time around.

However, when I change the date parameter, click "search" button, I get a blank RadGrid control. When I click search the second time, the grid is populated. When I walk through the code, I get an error message

Column 'ID' does not belong to table Table.

How can I resolve the issue of having to click search twice to display data ?


protected void btnSubmit_OnClick(object sender, EventArgs e)
{
    try
    {
        ViewState["newset"] = null;
        CreateDatasource();
        this.RadGrid1.DataBind();
        this.RadGrid1.CurrentPageIndex = 0;
        ViewState["newset"] = "new";   
         
        string idex = this.hdnindex.Value;
        if (idex != string.Empty)
            this.RadGrid1.MasterTableView.Items[int.Parse(idex)].Selected = true;
         
     }
     catch (Exception ex) {
        this.lblMessage.Text = ex.Message;
     }        
}
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    try
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            HyperLink hLink = (HyperLink)item["ViewHyperLink"].Controls[0];
            if (hLink != null)
                hLink.Attributes.Add("onclick", "selectMe('" + item.ItemIndex + "');");
        }
    }
    catch (Exception ex)
    {
        this.lblMessage.Text = ex.Message;
    }
}

In the code behind above, when this.RadGrid1.DataBind() is called, the code steps into `RadGrid1_ItemCreated` loops through the if statement a few times, them goes into the if statement, comes out of the function, and then the catch statement of btnSubmit is called, which displays the error message "Column ID does not belong to table Table".   

Any ideas on how to resolve this?
AAA
Top achievements
Rank 1
 answered on 11 Apr 2013
3 answers
161 views
Hi,

How to get uploading file size on select event in client side?
I need to get uploading file size before a file will be uploaded.

Thank you in advance.
Kate
Telerik team
 answered on 11 Apr 2013
0 answers
121 views
Here's the working code:

In the page.aspx.cs, I define a static variable:

private static TextBox txtName;

 

In the Page_Load() event, I initialize it:

txtName = (TextBox)RadPanelBar1.FindItemByValue("Add").Controls[0].FindControl("TxtName");


The questions is:
1- I had to make the textbox "static" to make the code work, why?
2- The initialization code didn't work when I put it in the if (!IsPostBack) block, I had to make it run  in every page load. why? and is there a better approach to achieve the same functionality?

 

 

 

 

Mohamed
Top achievements
Rank 1
 asked on 11 Apr 2013
5 answers
221 views
Hi all -

I am having an issue with the RadNumericTextBox that hopefully someone knows the solution to.  If I have the Input set to numeric and I copy-paste "$12.53" (or any other currency value), the result is that the value in the input ends up as "0.12" (or 0.[first two digits]).  It seems like, instead, the input box should be ignoring all characters other than acceptable numeric values.  This can be duplicated in the online example.  Anyone have any idea how to resolve this?

Thanks,
Ryan
Vasil
Telerik team
 answered on 11 Apr 2013
4 answers
547 views
Hi,

In the code below I keep getting an error on this line when the code executes: RadPanelBar rpb = (RadPanelBar)pv.Controls[0];
The error is an unable to cast object error.

Any idea how to resolve this? 

protected void RadButtonExpandAll_Click(object sender, EventArgs e)
        {
            int selectedIndex = RadTabStrip1.SelectedIndex;
            if (selectedIndex >= 0)
            {
                RadPageView pv = RadMultiPage1.PageViews[selectedIndex];
                RadPanelBar rpb = (RadPanelBar)pv.Controls[0]; // This is what errors //


                foreach (RadPanelItem r in rpb.Items)
                {
                    r.Expanded = true;

                }

            }
        }

Thanks,

Kevin


Kevin
Top achievements
Rank 1
 answered on 11 Apr 2013
1 answer
75 views
Hello,

We just upgraded our old ASP.NET AJAX components. It turns out that columns with visible = false does not get populated (for better performance). However we have a lot of hidden columns, like ID columns, that we use for in-line editing etc.

Is there anyway to populate these columns? Or do we have to change them all to visible and hide them in the PreRender event? (Which makes the markup very confusing, as you have to go to code behind to see which columns are actually visible on the page)
Oxygen
Top achievements
Rank 1
 answered on 11 Apr 2013
0 answers
60 views

Has anyone come up with a good solution? I’ve tried so many different ways and still having the problem. I was able to just hard code it on one of my pages because there was only 5 items. One of my other pages has 55 items and I need a fix to this. I have other web pages that will be impacted as well. Any solutions that worked for other folks would be appreciated. Here is one link I’ve tried:

http://stackoverflow.com/questions/5584500/ordered-list-showing-all-zeros-in-ie9

Other situation I tried:

I just tried the code below and have the following error: Microsoft JScript runtime error:

Unable to set value of the property 'innerHTML': object is null or undefined

<!DOCTYPE html> <HTML> <HEAD> <TITLE>IE9 Ordered List Zero Bug</TITLE> </HEAD> <BODY> <DIV id="dv1"> <OL> <LI>AAA</LI> <LI>BBB</LI> </OL> </DIV> <DIV id="dv2"></DIV> <SCRIPT type="text/javascript"> document.getElementById("dv1").innerHTML = "<ol><li>XXX</li><li>YYY</li></ol>"; var container = document.createElement('span'); container.style.display = "none"; document.getElementById("dv2").appendChild(container); </SCRIPT> </BODY> </HTML>

Link: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/7b278286-4d47-4556-aa57-cbaf68edeef8

ttaylor29
Top achievements
Rank 1
 asked on 11 Apr 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?