Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
126 views
Hello,

Everything seems to be working except that I have two labels and I'm getting the wrong rating in my "Your rating is" label. The average rating works fine and displays in the second label. Also, the stars display the correct average on page load. But as soon as I choose a rating, it displays the AVERAGE of the average and what I rated.

For example: If there is an average of 3.6 on page load and then I rate a 5, it will display 3.642857 in the "Your rating is" label.

I have posted the code below. Any help would be greatly appreciated!
Imports System
Imports System.Collections.Generic
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
 
Imports Telerik.Web.UI
Imports System.Data
Imports System.Data.SqlClient
 
Partial Public Class _2014
    Inherits System.Web.UI.Page
 
    Protected Sub RadRating_Rate(sender As Object, e As EventArgs)
        Dim rating As RadRating = DirectCast(sender, RadRating)
        If rating.ID = "RadRating1" Then
 
            Label1.Text = "Your Rating is: " + "<span style='color:Red'>" + RadRating1.Value.ToString + "</span>"
 
            AddRating(RadRating1.Value, "Amanda", 20141)
        End If
 
        If rating.ID = "RadRating2" Then
 
        End If
 
        If rating.ID = "RadRating3" Then
 
        End If
        If rating.ID = "RadRating4" Then
 
        End If
 
    End Sub
 
 
    Public Sub AddRating(ByVal rateVal As Object, ByVal picName As String, ByVal picId As Integer)
 
        Dim cnstr2 = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString())
        Dim cmd2 = New System.Data.SqlClient.SqlCommand("INSERT INTO Ratings(Rating,CreateDate,name,PicID) VALUES (@rating, @date , @name, @picID)", cnstr2)
        cmd2.CommandType = System.Data.CommandType.Text
        cmd2.Parameters.AddWithValue("@rating", rateVal)
        cmd2.Parameters.AddWithValue("@date", Date.Now)
        cmd2.Parameters.AddWithValue("@name", picName)
        cmd2.Parameters.AddWithValue("@picID", picId)
        'cmd2.Parameters.AddWithValue("@ip", ip)
 
        cnstr2.Open()
 
        cmd2.ExecuteNonQuery()
        cnstr2.Close()
 
    End Sub
 
    Public Function GetCount(ByVal picID As Integer) As Decimal
        Dim theCount As Decimal = 0.0
 
        'Dim currentAverageRating As Object = Vehicles.Rows(dataItem.ItemIndex + RadGrid1.CurrentPageIndex * RadGrid1.PageSize)(2)
        Dim cnstr2 = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString())
        Dim rdr As SqlDataReader
        Dim cmd2 = New System.Data.SqlClient.SqlCommand("SELECT AVG(Rating) AS Total FROM Ratings  WHERE PicID = @picID ", cnstr2)
        cmd2.CommandType = System.Data.CommandType.Text
        cmd2.Parameters.AddWithValue("@picID", picID)
        cnstr2.Open()
 
        rdr = cmd2.ExecuteReader
 
        If rdr.HasRows Then
 
            rdr.Read()
            If Not IsDBNull(rdr.GetValue(rdr.GetOrdinal("Total"))) Then
                theCount = rdr.GetValue(rdr.GetOrdinal("Total"))
            End If
        End If
        rdr.Close()
 
        cnstr2.Close()
        Return theCount
    End Function
 
 
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
 
        RadRating1.DbValue = GetCount(20141)
 
        'Label1.Text = "Your Rating is: " + "<span style='color:Red'>" + RadRating1.Value.ToString + "</span>"
        Label2.Text = "Average Rating is: " + "<span style='color:Red'>" + Convert.ToString(Format(GetCount(20141), "#.#")) + "</span>"
    End Sub
 
 
End Class

And here is the HTML:
<telerik:RadRating ID="RadRating1" Precision="Item" Value="0" ItemCount="5" runat="server" AutoPostBack="true" OnRate="RadRating_Rate">
                        </telerik:RadRating>
                        <asp:Label ID="Label1" runat="server" ForeColor="Green"></asp:Label>
                        <asp:Label ID="Label2" runat="server" ForeColor="Green"></asp:Label>
Ianko
Telerik team
 answered on 24 Dec 2014
7 answers
151 views
When I enter a span tag in the editor content, the DOM inspector shows it as a font tag.

You can see this on the demos. Just clear the content in the editor, go the html view, and type in very simple html like this: <span>hello</span>

Switch to design view and check it in the inspector - it is now called 'font'. The actual html is not changed (it is still a span), but the inspector gets it wrong.

​
Ianko
Telerik team
 answered on 24 Dec 2014
2 answers
54 views
Hi!
When I insert an appointment in advanced form, the start/end time combos have items until 17:30, while I set the business hour to 20:00.

How can I have those combos have items to 20:00?

Thanks!
Mavel
Top achievements
Rank 1
 answered on 24 Dec 2014
1 answer
391 views
Hello all:

I followed the online documentation, but cannot get the RadTabStrip to correctly change the page when clicked. I used a RadTabStrip, Added a MultipageView, and then added page views but nothing changes when I click the tabs. The code is shown below. Note I am using CodeBehind files so need to have the Tab change action in the code behind.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<%@ 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></title>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
  <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
    </script>
</telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
    <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>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div style="z-index: 102; left: 0px; width: 800px; position: absolute; top: 0px; height: 1000px">
      <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" OnAjaxRequest="RadAjaxPanel1_AjaxRequest" Height="692px" Width="798px">
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0">
          <Tabs>
            <telerik:RadTab runat="server" Selected="True" Text="Store Information" PageViewID="RadPageView1">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="General Information" PageViewID="RadPageView2">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#CCC0DA" Text="Fruits">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#C4BD97" Text="Nuts &amp; Ginseng">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#C4D79B" Text="Vegetables">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#B7DEE8" Text="Fish &amp; Shell Fish">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#E6B8B7" Text="Beef &amp; Veal">
            </telerik:RadTab>
          </Tabs>
        </telerik:RadTabStrip>
        <telerik:RadMultiPage ID="RadMultiPage1" runat="server" Height="365px" SelectedIndex="0">
          <telerik:RadPageView ID="RadPageView1" runat="server" Height="360px" Width="787px">
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Store Information"></asp:Label>
            <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Store Name:"></asp:Label><asp:TextBox ID="txtStoreName" runat="server"></asp:TextBox>
            <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Store ID Number:"></asp:Label><asp:TextBox ID="txtStoreID" runat="server"></asp:TextBox>
            <asp:Label ID="Label4" runat="server" Font-Bold="True" Text="Corporate Name:"></asp:Label><asp:TextBox ID="txtCorpName" runat="server"></asp:TextBox>
            <asp:Label ID="Label5" runat="server" Font-Bold="True" Text="Store Address:"></asp:Label><asp:TextBox ID="txtAddress1" runat="server"></asp:TextBox>
            <asp:Label ID="Label6" runat="server" Font-Bold="True" Text="City, State, Zip:"></asp:Label><asp:TextBox ID="txtCityStateZip" runat="server"></asp:TextBox>
            <asp:Label ID="Label7" runat="server" Font-Bold="True" Text="Store Phone Number:"></asp:Label><asp:TextBox ID="txtStorePhone" runat="server"></asp:TextBox>
            <asp:Label ID="Label8" runat="server" Font-Bold="True" Text="PACA License #:"></asp:Label><asp:TextBox ID="txtPACA" runat="server"></asp:TextBox>
          </telerik:RadPageView>
          <telerik:RadPageView ID="RadPageView2" runat="server" Height="360px" Width="787px">
          </telerik:RadPageView>
        </telerik:RadMultiPage>
        <asp:TextBox ID="txtDebug" runat="server" style="z-index: 102; left: 6px; width: 400px; position: absolute; top: 548px; height: 400px" TextMode="MultiLine"></asp:TextBox>
            

      </telerik:RadAjaxPanel>


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

Plamen
Telerik team
 answered on 24 Dec 2014
5 answers
117 views
It's a pity that the GridTemplateColumn doesn't support standard filter editors based on either the DataType or DateField data type (e.g., a DateTime data type is rendered as though it was a GridDateTimeColumn filter editor).  This seems like an easy implementation if <FilterTemplate> is not included but filtering is turned on.  Or another idea would be an alternative to <FilterTemplate> that would turn on the standard filter editor and let you set attributes on that.  I really want the filter button without all the extra work.

But maybe this is a quick way around it?  This is the column in the grid:

<telerik:GridTemplateColumn HeaderText="Expires On" DataType="System.DateTime" Visible="true" ShowFilterIcon="true" ShowSortIcon="true" UniqueName="dpExpDate" DataField="EXPIRATION_DATE" AllowFiltering="true" SortExpression="EXPIRATION_DATE" AllowSorting="true" FilterListOptions="VaryByDataType" >
    <HeaderStyle Width="240px" />
    <ItemStyle Width="240px" />
    <ItemTemplate>
        <asp:Label runat="server" ID="lblExpDate" />
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadDateTimePicker runat="server" ID="dpExpDate" Skin="Office2010Blue" Width="220px">
            <DateInput Display="true" DisplayDateFormat="G" DateFormat="G" runat="server" Font-Size="13px" Font-Name="Arial" />
            <TimePopupButton Visible="false" />
        </telerik:RadDateTimePicker><asp:Label runat="server" ID="lblInsertIn" Text="In" />
        <telerik:RadDropDownList runat="server" ID="ddlInsertHours" Font-Names="Arial" Font-Size="13px" Width="80px" Skin="Office2010Blue" />
        <asp:Label runat="server" ID="lblInsertHours" Text="Hours" />
    </EditItemTemplate>
</telerik:GridTemplateColumn>

And here's what I did in grid_ItemCreated:

if (e.Item is GridFilteringItem)
{
    GridFilteringItem item = e.Item as GridFilteringItem;
    if (item["dpExpDate"].Controls[0] is TextBox)
    {
        DateTime value = DateTime.MinValue;
        DateTime.TryParse(gridBatches.MasterTableView.GetColumn("dpExpDate").CurrentFilterValue, out value);
 
        RadDateTimePicker pick = new RadDateTimePicker();
        pick.Width = Unit.Pixel(200);
        pick.DateInput.DateFormat = "G";
        pick.DateInput.DisplayDateFormat = "G";
        pick.TimePopupButton.Visible = false;
        pick.DateInput.Width = Unit.Pixel(180);
        pick.Skin = "Office2010Blue";
        pick.DateInput.Font.Size = FontUnit.Parse("13px");
        pick.DateInput.Font.Name = "Arial";
        if (!value.Equals(DateTime.MinValue)) pick.DbSelectedDate = value;
 
        item["dpExpDate"].Controls.RemoveAt(0);
        item["dpExpDate"].Controls.AddAt(0, pick);
    }
}

Any reason I can't do that?  It seems to filter perfectly and appears to fit in with the Telerik examples that just assume there's always TextBox in Controls[0] anyway.

Feedback?
Kostadin
Telerik team
 answered on 24 Dec 2014
1 answer
84 views
I currently have 3 listboxes - Each one contains a "CustomAttr" attribute.

Listbox1.items["CustomAttr"] = 1
Listbox2.items["CustomAttr"] = 2
Listbox3.items["CustomAttr"] = 3

Destination Listbox = DestinationListBox

So when I drag an item from Listbox 1 to DestinationListBox, the item in DestinationListBox will still maintain ["CustomAttr"] = 1 (I believe)

In the OnClientTransferring client event, is it possible to get a count of items in DestinationListBox by attribute? 

The reason I ask is I want to be able to add only 5 items of ["CustomAttr"]  = 1, and ensure that if that is the case from OnClientTransferring, I can cancel the event using args.set_cancel(true);


If anyone has a better way of carrying out this type of function, I would really appreciate the assistance..

Many thanks,
Laurence
Bozhidar
Telerik team
 answered on 24 Dec 2014
1 answer
156 views
Hi:

Just struggling tog et a very simple RadTabStrip POC working, am now getting an error:

Control 'ScriptManager1' of type 'ScriptManager' must be placed inside a form tag with runat=server.

However when I look at the code (pasted below) it seems to me the Scriptmanager tag is very clearly inside the form tag with the runat=server tag. Can anyone offer any suggestions?

John.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<%@ 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></title>
   </head>
<body>
    <form id="form1" runat="server">

    <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 ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <div style="z-index: 102; left: 0px; width: 800px; position: absolute; top: 0px; height: 1000px">
      <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="692px" Width="798px">
        <telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0">
          <Tabs>
            <telerik:RadTab runat="server" Selected="True" Text="Store Information" PageViewID="RadPageView1">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="General Information" PageViewID="RadPageView2">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#CCC0DA" Text="Fruits">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#C4BD97" Text="Nuts &amp; Ginseng">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#C4D79B" Text="Vegetables">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#B7DEE8" Text="Fish &amp; Shell Fish">
            </telerik:RadTab>
            <telerik:RadTab runat="server" BackColor="#E6B8B7" Text="Beef &amp; Veal">
            </telerik:RadTab>
          </Tabs>
        </telerik:RadTabStrip>
        <telerik:RadMultiPage ID="RadMultiPage1" runat="server" Height="365px" SelectedIndex="0">
          <telerik:RadPageView ID="RadPageView1" runat="server" Height="360px" Width="787px">
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Store Information"></asp:Label>
            <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Store Name:"></asp:Label><asp:TextBox ID="txtStoreName" runat="server"></asp:TextBox>
            <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Store ID Number:"></asp:Label><asp:TextBox ID="txtStoreID" runat="server"></asp:TextBox>
            <asp:Label ID="Label4" runat="server" Font-Bold="True" Text="Corporate Name:"></asp:Label><asp:TextBox ID="txtCorpName" runat="server"></asp:TextBox>
            <asp:Label ID="Label5" runat="server" Font-Bold="True" Text="Store Address:"></asp:Label><asp:TextBox ID="txtAddress1" runat="server"></asp:TextBox>
            <asp:Label ID="Label6" runat="server" Font-Bold="True" Text="City, State, Zip:"></asp:Label><asp:TextBox ID="txtCityStateZip" runat="server"></asp:TextBox>
            <asp:Label ID="Label7" runat="server" Font-Bold="True" Text="Store Phone Number:"></asp:Label><asp:TextBox ID="txtStorePhone" runat="server"></asp:TextBox>
            <asp:Label ID="Label8" runat="server" Font-Bold="True" Text="PACA License #:"></asp:Label><asp:TextBox ID="txtPACA" runat="server"></asp:TextBox>
          </telerik:RadPageView>
          <telerik:RadPageView ID="RadPageView2" runat="server" Height="360px" Width="787px">
          </telerik:RadPageView>
        </telerik:RadMultiPage>      
      </telerik:RadAjaxPanel>


    </div>
    </form>
</body>
</html>
Hristo Valyavicharski
Telerik team
 answered on 24 Dec 2014
5 answers
115 views
Not sure where to post this but I'm having a simple question please.

I'm using a RadMultiPage control with a few RadPageViews. Inside one of the pages, I would like to have a footer section at the bottom of the page. On the telerik help pages, it says header and footers are possible but I don't see the tag for it.

Here is an example of what I've got:

<telerik:RadMultiPage ID="RadMultiPage1" SelectedIndex="0" runat="server" >

<telerik:RadPageView ID="RadTabDetails" runat="server">
// some code here

// I want a footer here:
<footer> ... </footer>

</telerik:RadPageView>

...

 

 

 

 

 

 

 

 

="server">

<telerik:RadMultiPage ID="RadMultiPage1" SelectedIndex="0" runat="server" BorderStyle="Solid" BorderWidth="1" Width="800px" Height="600px">

<telerik:RadPageView ID="RadTabDetails" runat="server">

 

 

 

Ben
Top achievements
Rank 1
 answered on 23 Dec 2014
3 answers
528 views
I have the following scenario: 

<%-- UF --%>
    <tr>
        <td>
            <label>UF</label>
            <br />
            <telerik:RadComboBox ID="rcbUF" runat="server" CheckBoxes="True" EnableCheckAllItemsCheckBox="True" CausesValidation="false"
                Culture="pt-BR" CssClass="lt-width-10" MaxHeight="250" OnItemChecked="rcbUF_ItemChecked" AutoPostBack="true">
            </telerik:RadComboBox>
        </td>
    </tr>
    <%-- Rodovia --%>
        <tr>
            <td>
                <label>Rodovia</label>
                <br />
                <asp:UpdatePanel runat="server" ID="uppRodovia">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="rcbUF" />
                    </Triggers>
                    <ContentTemplate>
                        <telerik:RadComboBox ID="rcbRodovia" runat="server" CheckBoxes="True" EnableCheckAllItemsCheckBox="True" Culture="pt-BR" MaxHeight="250" CssClass="lt-width-10" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>


When an item is checked on rcbUF, the following method is called (something like that):

protected void rcbUF_ItemChecked(object sender, RadComboBoxItemEventArgs e)
    {
    if (rcbUF.HasSelectedValue())
    {
        var _listaUF = rcbUF.Items.Where(x => x.Checked).Select(x => x.Value).ToList();
        var _rodovias = Repositorio<Rodovia>.GetAll.Where(x => x.ListaUF.Any(y=>_listaUF.Contains(y.UF.Id))).Select(x => x.Id).ToArray();
         
        if (_listaUF.Count > 0)
        {
            rcbRodovia.Carregar<Rodovia>(x => x.Numero, x => x.Id,
                Constantes.TextoVazioEspaco,
                true,
                x => _rodovias.Contains(x.Id),
                x => x.Numero);
        }
        else
        {
            rcbRodovia.Carregar<Rodovia>(x => x.Numero, x => x.Id,
                Constantes.TextoVazioEspaco,
                true,
                x => x.Numero);
        }
         
        rcbRodovia.Items.Distinct();
        rcbRodovia.Enabled = true;
    }
    }

My problem is that everytime I click on the item instead of the checkbox, it triggers a postback (much on the OnItemSelected way), and I really don't want it to occur.

Later I tried setting the rcbUF OnClientSelectedIndexChanging event to trigger this function:

function OnClientSelectedIndexChanging(sender, args)
{
    args.set_cancel(true);
}

But the event never fires, like it does fire the codebehind event but not the client-side one.

Boyan Dimitrov
Telerik team
 answered on 23 Dec 2014
1 answer
45 views
I have several different pageviews within a multipage control that is within a tabstrip. My first tab/pageview contains fields that the each of the following pageviews needs access to. This is a multi-step, complex form that is not saved until the last step so I need to know what the values of the fields are currently on the unsaved form instead of say pulling them from a database.

I can find no way to access the field values before the form is submitted. I cannot read the values client-side (using jQuery) for tabs/pageviews that are not active as the fields are not in the DOM.  I cannot get any data from the viewstate as it is encrypted no matter what my web.config says to the contrary.  I can get data from Request.Form, but only for the fields that are on the tab that immediately precedes the current one, not from the whole form.

Is there some shadow copy of the DOM that is persisting the data across page loads? Or, better yet, some way to access the current form field values sever-side when the page reloads? 
 
I cannot be the first person to encounter this issue....
Hristo Valyavicharski
Telerik team
 answered on 23 Dec 2014
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?