Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
178 views
Hi there,

I have a radwindow that performs a search on data and displays a list within a repeater of options the user may select.
What I need to do is collect the repeater object and send back to the parent. 

I looked at some of your examples using javascript, the problem is using javascript to grab the data within the repeater is quite ugly.

Is there a way I can pass the code back via code behind?
So in my repeater I have a button "select" when user clicks the "select" button the radwindow closes and
the parent receives the selection. 

My repeater code

​<asp:Repeater ID="rptStores" runat="server" OnItemDataBound="rptStores_ItemDataBound">
<HeaderTemplate>
<table>
<tr style="color:#ffd700; font-weight:bold;">
<td>Store Name</td>
<td>City</td>
<td>Street</td>
<td>Distance(Mi.)</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="color:#fff;" onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor=''" class="<%# If(Container.ItemIndex Mod 2 = 0, "TRNormal", "TRAlt") %>">
<td style="padding: 4px;">
<asp:Label ID="lblDBAName" runat="server" Text='<%# Eval("DBAName") %>' />
<asp:HiddenField ID="hfRowID" runat="server" Value='<%# Eval("id") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblCity" runat="server" Text='<%# Eval("State") +"-"+ Eval("City")%>' />
<asp:HiddenField ID="hfState" runat="server" Value='<%# Eval("state") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblStreet" runat="server" Text='<%# Eval("Street1") %>' />
<asp:HiddenField ID="hfPhone" runat="server" Value='<%# Eval("phone") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblDistance" runat="server" Text='<%# Eval("distance") %>' />
</td>
<td>
<telerik:RadButton runat="server" Text="Select" ID="storeSelection2" CommandName="Process" Skin="Black" OnClientClicked="returnToParent"></telerik:RadButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:Label ID="lblEmptyData" Text="No Data To Display" runat="server" Visible="false"></asp:Label>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>


my vb

Protected Sub rptStores_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptStores.ItemCommand

Dim dbaName As Label
dbaName = CType(e.Item.FindControl("lblDBAName"), Label)

Dim city As Label
city = CType(e.Item.FindControl("lblCity"), Label)

Dim state As HiddenField
state = CType(e.Item.FindControl("hfState"), HiddenField)

Dim phone As HiddenField
phone = CType(e.Item.FindControl("hfPhone"), HiddenField)

Dim street1 As Label
street1 = CType(e.Item.FindControl("lblStreet"), Label)

Dim selectedID As HiddenField
selectedID = CType(e.Item.FindControl("hfRowID"), HiddenField)

ProcessButton(dbaName.Text, street1.Text, city.Text, state.Value, phone.Value, selectedID.Value)

End Sub

ProcessButton is called AFTER a return to parent javascript call.

Is this an option or do i really need to send object via javascript back to parent and then push into code behind.

Julius
Top achievements
Rank 1
 answered on 10 Jul 2016
10 answers
375 views
Hi-

I'm using a RadAjaxManager with some RadNumericTextBoxes and an asp:Button.  The button OnClick and the OnTextChanged are using the RadAjaxManager to update some Labels.

This works fine until I change the value in the RadNumericTextBox and then try to click on the button directly.  In this case, it seems to lose the click.

You can reproduce this by:
1) changing the values using the spinner in each of the two rad input boxes to verify that the "lblTotal" label changes.
2) click "OK" to show that the date is updated
3) change a value in one of the RadNumericTextBoxes using the keyboard and then clicking on the OK button directly.

You'll see that the date doesn't update---it's like an event is being lost somewhere.  This happens in both Firefox and IE8 on build 2009.02.0826.35.

Any idea what might cause that?

Thanks!

-Mike


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadAjaxProblem.aspx.cs" 
    Inherits="Ajax.RadAjaxProblem" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<!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>Test Ajax</title> 
</head> 
<body> 
 <form id="form1" runat="server"
    <asp:ScriptManager ID="scriptManagerProxy1" runat="server"
    </asp:ScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="radNumber1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblTotal" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnOk" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="radNumber2"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblTotal" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnOk" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="btnOk"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblMessage" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    
    <div style="margin:50px" > 
        <telerik:RadNumericTextBox ID="radNumber1" runat="server" Type="Number" MinValue="1" 
            AutoPostBack="true" NumberFormat-DecimalDigits="0" Width="75px" ShowSpinButtons="true" 
            Value="1" OnTextChanged="OnNumber1Changed" /> 
        plus 
        <telerik:RadNumericTextBox ID="radNumber2" runat="server" Type="Number" MinValue="1" 
            AutoPostBack="true" NumberFormat-DecimalDigits="0" Width="75px" ShowSpinButtons="true" 
            Value="1" OnTextChanged="OnNumber2Changed" /> 
        equals 
        <asp:Label runat="server" ID="lblTotal"></asp:Label>
        <p> 
            Message: 
            <asp:Label ID="lblMessage" runat="server" Text="..."></asp:Label> 
        </p> 
        <p> 
            <asp:Button runat="server" ID="btnOk" OnClick="btnOk_Click" Text="OK" /> 
        </p> 
    </div> 
    </form> 
</body> 
</html> 
 

using System; 
using Telerik.Web.UI; 
 
namespace Ajax 
    public partial class RadAjaxProblem : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
        } 
 
        private void UpdateTotal() 
        { 
            int arg1 = (int) (radNumber1.Value.HasValue ? radNumber1.Value.Value : 0); 
            int arg2 = (int) (radNumber2.Value.HasValue ? radNumber2.Value.Value : 0); 
            lblTotal.Text = String.Format("{0}", arg1 + arg2); 
        } 
 
        protected void OnNumber1Changed(object sender, EventArgs e) 
        { 
            UpdateTotal(); 
        } 
        protected void OnNumber2Changed(object sender, EventArgs e) 
        { 
            UpdateTotal(); 
        } 
 
 
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
             
        } 
 
        protected void btnOk_Click(object sender, EventArgs e) 
        { 
             
            lblMessage.Text = String.Format("OK clicked at " + DateTime.Now.ToLongTimeString()); 
        } 
    } 
 
Dürdane
Top achievements
Rank 1
 answered on 10 Jul 2016
1 answer
114 views

Hello

On a page I have RadNavigation menu with submenu and a AutoCompleteBox with OnEntryAdded event. If I put the AutoCompleteBox inside the UpdatePanel, after OnEntryAdded is fired, RadNavigation menu does not work anymore - it's blocked, I can't access submenu nodes. There is no javascript errors on the page, so I don't know how to fix this. Can you help me please.

I'm attaching the sample code which you can use to see the issue.

<%@ Page Title="" Language="VB"  AutoEventWireup="false" CodeFile="test1.aspx.vb" Inherits="test1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
          <form id="form1" enctype="multipart/form-data"  runat="server">

        <telerik:RadScriptManager ID="RadScriptManager1" EnableScriptGlobalization="true"  Runat="server">
        </telerik:RadScriptManager>
               <telerik:RadNavigation ID="radNav"  Skin="MetroTouch" Font-Size="Medium"  runat="server" RenderMode="Auto">
                <Nodes>
                    <telerik:NavigationNode Text="Test">
                        <Nodes>
                        <telerik:NavigationNode NavigateUrl="test1.aspx"  Text="Test 1"></telerik:NavigationNode>
                        <telerik:NavigationNode NavigateUrl="test1.aspx"  Text="Test 2"></telerik:NavigationNode>
                        </Nodes>
                    </telerik:NavigationNode>
                </Nodes>
                </telerik:RadNavigation>

              <asp:UpdatePanel runat="server" ID="up1">
                  <ContentTemplate>
                        <telerik:RadAutoCompleteBox  OnEntryAdded="drpLista_EntryAdded"  ID="RadAutoCompleteBox1" Width="180px"  runat="server" Skin="Bootstrap">
                        </telerik:RadAutoCompleteBox> 
                  </ContentTemplate>
              </asp:UpdatePanel>
                   

              </form>
    </body>
</html>

 

Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI

Partial Class test1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        BindToArrayList(RadAutoCompleteBox1)
    End Sub 'Page_Load


    Private Sub BindToArrayList(ByVal autoCompleteBox As RadAutoCompleteBox)
        Dim itemsList As New ArrayList()
        itemsList.Add("One")
        itemsList.Add("Two")
        itemsList.Add("Three")
        autoCompleteBox.DataSource = itemsList
    End Sub 'BindToArrayList

    Protected Sub drpLista_EntryAdded(sender As Object, e As AutoCompleteEntryEventArgs)
        
    End Sub


End Class

Peter Milchev
Telerik team
 answered on 08 Jul 2016
3 answers
49 views

On Firefox the Radeditor imagemanager window is:

 

1. Always sticking on top of browserwindow

2. not high enough for content, see screenshot.

Marc
Vessy
Telerik team
 answered on 08 Jul 2016
6 answers
262 views
01. protected void RDDL_Statut_Load(object sender, EventArgs e)
02.{
03.    DC_FiltragesDataContext Mydb = new DC_FiltragesDataContext();
04.    var results = (from U in Mydb.PLOP
05.                   select new { statut = U.STATUT}).Distinct();
06. 
07.    RDDL_Statut.DataSource = results;
08.    RDDL_Statut.DataTextField = "statut";
09.    RDDL_Statut.DataValueField = "statut";
10. 
11.    RDDL_Statut.DataBind();
12.    RDDL_Statut.Items.Insert(0, new DropDownListItem("--ALL STATUT--", "ALL"));
13. 
14.}

            Hi, I have an issue with my drop down list.

Lets say that i have a DropDownList Displaying : A, B ,C , D etc. And I need a default item.
Using this code , my data is not correctly bound.
The display of the DrowDownList Is the one i expected . But my "RDDL_Statut.SelectedItem.Value.ToString()" Is returning the Next Index.
When A is clicked I get B value.


Ivan Danchev
Telerik team
 answered on 08 Jul 2016
1 answer
72 views
Is they're a way to make the RadMenu responsive on desktop? I have setup the menu to use the auto render mode but it still wraps on desktops when the screen size is made smaller.
Ivan Danchev
Telerik team
 answered on 08 Jul 2016
1 answer
95 views

i have used demo code from the http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-item-template/defaultvb.aspx?show-source=true

and i got error message :

 

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Type 'Telerik.Web.UI.GridTemplateColumn' does not have a public property named 'clientitemtemplate'.
Source Error:
</telerik:GridBoundColumn>

<telerik:GridTemplateColumn UniqueName="TitleClientTemplateColumn" HeaderText="Title"> Line 30:

<clientitemtemplate>

<span style="#=formatTitle(ContactTitle)#">#=ContactTitle #</span>

</clientitemtemplate>

Viktor Tachev
Telerik team
 answered on 08 Jul 2016
0 answers
114 views

I seem to have problems using a RadProgressArea together with a webservice method called from client side.

If I on the other hand use a code behind function as the way of updating the progress, the updating of the progress works.
Why?
I will start with describing the working approach with code behind and then the client side calling a webservice approach.

 

Working setup
In the webpage, I have a telerik:RadProgressArea and a RadProgressManager:

<telerik:RadProgressArea ID="progressArea"
  ProgressIndicators="TotalProgressBar,TotalProgressPercent" Skin="Metro"
  HeaderText="Please wait!" runat="server"/>
 <telerik:RadProgressManager ID="progressManager" runat="server"/>

 

I also have an asp:Button like:

OnClick="Button1_Click"

In that code behind eventhandler I perform a lot of work. It has a loop where it performs some tasks. Before the loop, I have this code:

var progress = RadProgressContext.Current;
 var num = 0;
 var maxnum = tasks.Count();
 
 progress.PrimaryPercent = 0;
 progress.PrimaryValue = 0;
 progress.PrimaryTotal = maxnum;

After every task, in other words in the end of the loop, I update PrimaryPercent and PrimaryValue like:

num++;
progress.PrimaryPercent = num * 100 / maxnum;
progress.PrimaryValue = num;

and after that loop, the eventhandler ends with

rapMain.ResponseScripts.Add("CloseWindow()");

and that javascript function closes the window.
This setup works, the progressbar gets updated as it should.

Here is the a response to Telerik.RadUploadProgressHandler.ashx?RadUrid=22b0e25c-69c9-4be7-8d7e-33b818854f35&RadUploadTimeStamp=1467900709164&:

var rawProgressData = {InProgress:true,ProgressCounters:true,PrimaryPercent:'81',PrimaryValue:'111',PrimaryTotal:'136'};

 

The non working setup (using a WebService)
I have an aspx file with an identical setup as in the working case.

I call the web method with javascript:

var progressBar = $find(progressAreaId);
progressBar.show();
 
var pm = getRadProgressManager();
pm.startProgressPolling();
 
$.ajax({
  type: "POST",
  url: "Foobar.asmx/Methodname",
  data: {id:2343},
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg)
  {
    progressBar.hide();
    alert("done!");
  }
});

(If I do not call pm.startProgressPolling, the ashx will not be called frequently to get the progress values).

The web method looks like this:

[WebMethod(EnableSession = true)]
public bool MethodName(int id)
{
    var progress = RadProgressContext.Current;
 
    /* some code that retrieves an array of tasks */
 
    var maxnum = tasks.Count;
    progress.PrimaryPercent = 0;
    progress.PrimaryValue = 0;
    progress.PrimaryTotal = maxnum;
 
    foreach (var task in tasks)
    {
        /* code that performs task */
        result++;
 
        progress.PrimaryPercent = result * 100 / maxnum;
        progress.PrimaryValue = result;
    }
 
   return true;
}

It seems like RadProgressContext.Current contains the expected data. If I manipulate RadProgressContext.Current.CurrentOperationText in the code behind (in Page_Load), the web service will be able to read that string.

However, the progress will never be updated and then the web service method has run, the progressbar will dissapear as it should.

The polling will not get the expected data but say that InProgress is false.
Here is the a response to Telerik.RadUploadProgressHandler.ashx?RadUrid=a1dcfc89-bd8c-43d3-b88f-718890d7fc04&RadUploadTimeStamp=1467898578437&:

var rawProgressData = {InProgress:false,ProgressCounters:false};


This is a copy of a stackoverflow posting at http://stackoverflow.com/questions/38248183/progressarea-will-not-get-updated-from-webmethod

Also it is a copy of the forum posting http://www.telerik.com/forums/progressarea-will-not-get-updated-from-webmethod that I posted in the wrong forum topic.

Anders
Top achievements
Rank 1
 asked on 08 Jul 2016
4 answers
104 views

Hi Telerik Team, you are doing an amazing work but today I need some more information.

 

I need to focus the gantt view on a task while double clicking on its name.

I look forward something like the "ScrollToDateTime" function or something like that.

I already tried this solution : http://www.telerik.com/forums/scroll-to-current-day but it could not find the ".bind" property of the "._widget".

 

I also need to directly open a popup after the insertion of a new task. The problem is that I can't find the task ID in the OntaskInsert event.

 

Could you please help me ?

Druoton
Top achievements
Rank 1
 answered on 08 Jul 2016
1 answer
353 views

Hi,

Trying to gather some info on how to bind the model to a RadGrid when in Edit mode for a dropdown list (or even a RadDropDownList).

I have the following markup:

<telerik:RadGrid ID="rgTest" runat="server"
    AutoGenerateColumns="false"
    AllowPaging="true"
    AllowSorting="true"
    ClientSettings-EnableRowHoverStyle="true"
    OnItemCommand="rgTest_ItemCommand"
    OnDeleteCommand="rgTest_DeleteCommand"
    OnItemDataBound="rgTest_ItemDataBound"
    PageSize="10" >
    <PagerStyle Mode="NextPrevAndNumeric" />
    <MasterTableView AutoGenerateColumns="false"
        DataKeyNames="Id"
        SelectMethod="GetData"
        UpdateMethod="UpdateData"
        ItemType="Model.TestData"
        CommandItemDisplay="Top">
        <CommandItemSettings ShowAddNewRecordButton="false" />
        <Columns>
            <telerik:GridButtonColumn
                UniqueName="EditItem"
                CommandName="Edit"
                ItemStyle-Width="40"
                ItemStyle-HorizontalAlign="Center"
                ItemStyle-ForeColor="White"
                Text="Edit"
                ButtonType="LinkButton"
                ButtonCssClass="btn btn-primary btn-sm">
            </telerik:GridButtonColumn>
            <telerik:GridTemplateColumn UniqueName="Id" HeaderText="ID">
                <ItemTemplate>
                    <asp:Label ID="lblID" runat="server" Text='<%# Item.Id %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="TestTitle" HeaderText="Title">
                <ItemTemplate>
                    <asp:Label ID="lblTestTitle" runat="server" Text='<%# Item.TestTitle %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="TestType" HeaderText="Type">
                <ItemTemplate>
                    <asp:Label ID="lblTestType" runat="server" Text='<%# Item.TestType %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
         
        <EditFormSettings EditFormType="Template">
            <FormStyle />
            <FormTemplate>
                <label for="txtTestTitle" class="col-md-4 control-label">Title</label>
                <asp:TextBox ID="txtTestTitle" runat="server" ClientIDMode="Static" Text='<%# BindItem.TestTitle %>' CssClass="form-control" autocomplete="off"></asp:TextBox>
                <label for="ddlType" class="col-md-4 control-label">Type</label>
                <asp:DropDownList ID="ddlType" runat="server" Width="100%" CssClass="form-control" >
                </asp:DropDownList>
            </FormTemplate>
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

My code behind as follows:

public IQueryable<Model.TestData> GetData()
{
    DbContext ctx = new DbContext();
    return (from c in ctx.TestData
       select c).OrderBy(a => a.Id);
}
 
public void UpdateWebProjectRequest(int Id)
{
    using(DbContext ctx = new DbContext())
    {
        Model.TestData td = ctx.TestData.Where(a => a.Id == Id).FirstOrDefault();
 
        TryUpdateModel(td);
        if (ModelState.IsValid)
        {
         ctx.SaveChanges();
        }
    }
}
 
protected void rgTest_ItemDataBound(object sender, GridItemEventArgs e)
{
    if(e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editItem = (GridEditableItem)e.Item;
 
        // Populate the DropdownList here.
        DropDownList ddlType = (DropDownList) editItem.FindControl("ddlType");
         
        // Some method here to load the dropdownlist.
        var list = new List<Models.TestTypes>();
        ddlType.DataSource = lst;
        ddlType.DataValueField = "TypeId";
        ddlType.DataTextField = "TypeName";
        ddlType.DataBind();

        ddlType.SelectedValue = DataBinder.Eval(editItem.DataItem, "TestType").ToString();

    }
}

The issue I am having is that when I changed the value in the dropdownlist and invoke an update command, the new value selected on the dropdownlist is not being propagated to the model, hence, the correct data is not being saved.

I've looked at the article in this link:

http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/custom-edit-forms

But I am not able to figure out how to bind the dropdownlist value properly.

Any suggestions or ideas would be appreciated.

Thanks.

~A

 

Viktor Tachev
Telerik team
 answered on 08 Jul 2016
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?