Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
51 views
Hi;
Is the source code available for the four independent demos?
Telerik Sales Dashboard, Telerik Web Mail, Telerik Rent a Car and Telerik Event Scheduler

Thanks!
Ben Hayat
Top achievements
Rank 2
 answered on 08 Jul 2011
2 answers
164 views
I have a RadGrid using a custom skin that is inside of a row in a table with alternating row colors. The background color for the table row seems to be overriding the alternating row color for the RadGrid. i checked all the styles on my grid using Firebug and the .rgAltRow class is on my RadGrid row with the correct background color in the CSS. I have tried putting !important after the color and that changed nothing.

.RadGrid_MailMerlin .rgAltRow
{
    background: #ededed;
}

I have attached a screenshot of my grid. If you need any other code/css please let me know!

Thanks in advance.

Dan
Dan Miller
Top achievements
Rank 1
 answered on 08 Jul 2011
1 answer
231 views
Hi

I am attempting to add RadToolBarbuttons to a RadToolBar I have defined in my aspx file.

I am adding the elements successfully after creating them with the following server side code.

 

 


RadToolBarButton
rtb = new RadToolBarButton();

 

rtb.Group = sGroup;

rtb.CheckOnClick =

 

true;

 

rtb.Checked =

 

false;

 

rtb.PostBack =

 

true;

 

rtb.ImageUrl = sImageUrl;

rtb.Value = sValue;

rtb.ToolTip = sToolTip;

I add the rtb object, actually more than one, to my RadToolBar.

 


They all appear correctly in my UI.

However as soon as I mouse over them I get an exception.

I noticed the rendered html is different from an in-line RadToolBarButton.

The dynamically created buttons don't have _item["object Object"] or _itemTypeName["Telerik.Web.UI.RadToolBarButton"] attributes.

What am I missing?

TIA

 

Dimitar Terziev
Telerik team
 answered on 08 Jul 2011
4 answers
124 views
Good morning, I'm trying to change my old code to upload images. But it hascomplicated everything. I can not find how to adapt what I have to control radupload. Help me please.

Example
In this part of code

Public Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName AsStringByVal strImgFolder As String)

        Dim strImageFolderPath As String

        Dim strImagePath As String

        Try

            '   Construct saving path

            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)

            strImagePath = Path.Combine(strImageFolderPath, strPictureName)

            '   Upload image this part is not as fit

            FileUploader.PostedFile.SaveAs(strImagePath)

            FileUploader.PostedFile.InputStream.Dispose()

            FileUploader.Dispose()

        Catch ex As Exception

            'Throw ex

        End Try

    End Sub



All code here

Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) HandlesButton2.Click

        Dim tamano_fotoP As Integer

        Dim tamano_fotoG As Integer

        tamano_fotoP = 235

        tamano_fotoG = 649

        Try

            Dim strGuid As String = ""

            Dim strPicExtension As String = ""

            Dim strFileName As String = ""

            If PhotoUpload.HasFile = True Then

                strGuid = fnGuid()

                strPicExtension = fnGetPictureExtension(PhotoUpload.FileName)

                strFileName = strGuid & strPicExtension

                txtfoto.Text = strFileName

                If strPicExtension <> "none" Then

                    subAddNewPicture(PhotoUpload, strFileName, "Imagenes")

                    Resize_Image(tamano_fotoP, tamano_fotoP, strFileName, "~/Imagenes/","P/")

                    Resize_Image(tamano_fotoG, tamano_fotoG, strFileName, "~/Imagenes/","G/")

                    sqldata.Insert()

                    PhotoUpload.PostedFile.InputStream.Dispose()

                    PhotoUpload.Dispose()

                    GC.Collect()

                    eliminar_foto(strFileName, "")

                Else

                    lblmensaje.Text = "Por favor seleccione una imagen..."

                End If

            Else

                lblmensaje.Text = "Por favor seleccione una imagen..."

            End If

            lblmensaje.Visible = True

        Catch ex As Exception

        End Try

    End Sub

    Protected Sub eliminar_temporales()

        Dim file() As FileInfo

        Dim i As Integer

        Dim txtpath As String

        txtpath = Path.Combine(Request.PhysicalApplicationPath, "Imagenes")

        If txtpath <> "" Then

            Dim dir As New DirectoryInfo(txtpath)

            file = dir.GetFiles()

            If file.Length > 0 Then

                For i = 0 To file.Length - 1

                    Try

                        file(i).Delete()

                    Catch ex As Exception

                        'Throw ex

                    End Try

                Next

            End If

        End If

    End Sub

    Public Sub eliminar_foto(ByVal nombre_foto As StringByVal folder As String)

        Dim strImagePath, strImageFolderPath As String

        Try

            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, "Imagenes"& folder)

            strImagePath = Path.Combine(strImageFolderPath, nombre_foto)

            System.IO.File.Delete(strImagePath)

        Catch ex As Exception

            'Throw ex

        End Try

    End Sub

    Public Sub Resize_Image(ByVal intMaxWidth As ShortByVal intMaxHeigth As ShortByValfoto As StringByVal folder As StringByVal atributo As String)

        Dim img As Image

        img = System.Drawing.Image.FromFile(MapPath(folder & foto))

        Dim oImg As Bitmap = New System.Drawing.Bitmap(img)

        'Assign image dimensions

        Dim oldWidth As Integer

        Dim oldHeight As Integer

        Dim newWidth As Integer

        Dim newHeight As Integer

        Dim ratio As Decimal

        oldWidth = oImg.Width

        oldHeight = oImg.Height

        ratio = oldWidth / oldHeight

        newWidth = intMaxWidth

        newHeight = newWidth / ratio

        'rutina para ver si la foto es mas pequena del tamano a recortar dejandola igual

        If oImg.Width < intMaxWidth Then

            newWidth = oImg.Width

            newHeight = oImg.Height

        End If

        Dim OutputBitmap As Bitmap = New Bitmap(oImg, CInt(newWidth), CInt(newHeight))

        Dim encoderParams As System.Drawing.Imaging.EncoderParameters = NewSystem.Drawing.Imaging.EncoderParameters()

        Dim quality As Long

        Dim imageFormat = img.RawFormat

        Dim myresizer As Graphics

        myresizer = Graphics.FromImage(OutputBitmap)

        'myresizer.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality

        'myresizer.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality

        myresizer.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

        myresizer.DrawImage(img, 0, 0, newWidth, newHeight)

        'Compress image

        Dim comp As Integer

        If atributo = "G/" Then

            comp = 60

        Else

            comp = 70

        End If

        quality = comp ' 0 to 100 - 100 highest quality

        Dim encoderParam As System.Drawing.Imaging.EncoderParameter = NewSystem.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality)

        encoderParams.Param(0) = encoderParam

        Dim arrayICI As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()

        Dim jpegICI As ImageCodecInfo

        Dim x As Integer

        For x = 0 To arrayICI.Length - 1

            If (arrayICI(x).FormatDescription.Equals("JPEG")) Then

                jpegICI = arrayICI(x)

                Exit For

            End If

        Next

        'Save original image

        If Not jpegICI Is Nothing Then

            OutputBitmap.Save(Server.MapPath(folder) & atributo & foto, jpegICI, encoderParams)

        End If

        '  clean up

        OutputBitmap.Dispose()

    End Sub

#Region "Public Functions"

    '   Adds picture to specified folder

   

Public Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName AsStringByVal strImgFolder As String)

        Dim strImageFolderPath As String

        Dim strImagePath As String

        Try

            '   Construct saving path

            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)

            strImagePath = Path.Combine(strImageFolderPath, strPictureName)

            '   Upload image ACTUALIZADO

            FileUploader.PostedFile.SaveAs(strImagePath)

            FileUploader.PostedFile.InputStream.Dispose()

            FileUploader.Dispose()

        Catch ex As Exception

            'Throw ex

        End Try

    End Sub

    '   Function to generate a GUID using current date and time

    Public Function fnGuid() As String

        Dim strGuid As String = ""

        Try

            With Today

                strGuid = .Year & .Month & .Day & Now.Hour & Now.Minute & Now.Second

            End With

        Catch ex As Exception

            Throw ex

        End Try

        '   returning the guid generated

        Return strGuid

    End Function

    '   Returns true if file name has the extension .jpg, .gif, .jpeg

    Public Function fnGetPictureExtension(ByVal strPictureName As StringAs String

        Try

            With strPictureName.ToUpper

                If .EndsWith(".JPG"Then

                    Return ".JPG"

                ElseIf .EndsWith(".GIF"Then

                    Return ".GIF"

                ElseIf .EndsWith(".JPEG"Then

                    Return ".JPEG"

                ElseIf .EndsWith(".PNG"Then

                    Return ".PNG"

                ElseIf .EndsWith(".BMP"Then

                    Return ".BMP"

                End If

            End With

        Catch ex As Exception

            Throw ex

        End Try

        ' Else if has no extension so it returns ""

        Return "none"

    End Function

#End Region


Dimitar Terziev
Telerik team
 answered on 08 Jul 2011
4 answers
72 views
Hello,

I've been noticing an odd behavior... I have two toolbar items that are CheckOnClick="true" Checked="false" AllowSelfUncheck="true"... when the items are clicked in FF5 (assumedly 4 as well), they look fine... but then when I click to "uncheck" them, the buttons stay depressed / in the checked style UNTIL I click somewhere else on the form... almost like they are keeping a focus or something that maintains the checked state.

I only see this on Firefox... any ideas?

Thanks,
-Brian
Brian Azzi
Top achievements
Rank 2
 answered on 08 Jul 2011
3 answers
192 views
Hi there!
I've spent some time looking through forums, watching videos and going through the tutorials, but I can't seem to find an easy way to create new aspx pages in my web application, that include all the 'boilerplate' code as supplied by Telerik's new project wizard.

When I create a new project with Telerik's VSE, I get a project that looks like this:

    Refer to attched file: "default_aspx_in_solution.png"


If one opens the markup for default.aspx, the 'boilerplate' code for all the Telerik AJAX 'stuff' is apparent:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!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>
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <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>
 
    </div>
    </form>
</body>
</html>


However if I now create a new webforms page I get the standard template as defined by MSFT:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyNewForm.aspx.cs" Inherits="MyRadControlsWebApp.MyNewForm" %>
 
<!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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     
    </div>
    </form>
</body>
</html>


On large websites it will be a real pain to continuously copy and paste the Telerik 'template' into every new page that is created.

Surely there is an easy way to create a new aspx page that automatically includes all of Telerik's boilerplate code.

Can anyone help?

Thanks,

Paul.
Erjan Gavalji
Telerik team
 answered on 08 Jul 2011
3 answers
108 views
I have a user control that contains a RadGrid with the EditLink column,

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Prospects.ascx.cs" Inherits="Prospects" %>  
    <telerik:RadCodeBlock ID="radcodeProspects" runat="server">
        <script type="text/javascript">
            function ShowEditForm(id, rowIndex) {
                alert(id);
                window.radopen("EditContact.aspx?ContactID=" + id, "UserListDialog");
                return false;
            }
            function ShowInsertForm() {
                window.radopen("EditContact.aspx", "UserListDialog");
                return false;
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
                else {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                }
            }
  
        </script>
    </telerik:RadCodeBlock>
     <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="prospectGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="prospectGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="prospectGrid" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
  
    <telerik:RadGrid AllowSorting="true" BackColor="#393939"
        ID="prospectGrid" runat="server" AllowPaging="true" PageSize="15" 
        Width="980px" CssClass="productsGrid" 
        OnPreRender="prospectGrid_PreRender"  OnItemCreated="prospectGrid_ItemCreated"
        OnNeedDataSource="prospectGrid_NeedDataSource" style="outline:0">
        <MasterTableView AutoGenerateColumns="false" PagerStyle-Mode="NextPrevAndNumeric" AllowFilteringByColumn="false"
                         DataKeyNames="OrderID" ClientDataKeyNames="OrderID" TableLayout="Fixed">
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" HeaderText="ProspectID" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderStyle-Width="70px"  FilterControlWidth="35px">
                </telerik:GridBoundColumn>
                <telerik:GridNumericColumn DataField="Freight" HeaderText="Freight" DataFormatString="{0:c}" HeaderStyle-Width="110px" FilterControlWidth="60px">
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="ShipName" HeaderText="Prospect Name" HeaderStyle-Width="300px" FilterControlWidth="260px">
                </telerik:GridBoundColumn>      
                <telerik:GridBoundColumn DataField="ShipCountry" HeaderText="Country" FilterControlWidth="70px">
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="OrderDate" HeaderText="Order Date" DataFormatString="{0:d}" FilterControlWidth="95px">
                </telerik:GridDateTimeColumn>
                <telerik:GridDateTimeColumn DataField="ShippedDate" HeaderText="Shipping Date" DataFormatString="{0:d}" FilterControlWidth="95px">
                </telerik:GridDateTimeColumn>
                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                    <ItemTemplate>
                        <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowDragToGroup="false" EnableRowHoverStyle="true">
            <Selecting AllowRowSelect="true" />
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="360px" />
        </ClientSettings>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="320px"
                    Width="310px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"
                    Modal="true" />
            </Windows>
    </telerik:RadWindowManager>
  
    <telerik:RadAjaxLoadingPanel ID="ProductsLoadingPanel" runat="server"></telerik:RadAjaxLoadingPanel>

and the onClick code is generated in the code-behind file,

protected void prospectGrid_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
            editLink.Attributes["href"] = "#";
            editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"], e.Item.ItemIndex);
        }
    }
  
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            prospectGrid.MasterTableView.SortExpressions.Clear();
            prospectGrid.MasterTableView.GroupByExpressions.Clear();
            prospectGrid.Rebind();
        }
        else if (e.Argument == "RebindAndNavigate")
        {
            prospectGrid.MasterTableView.SortExpressions.Clear();
            prospectGrid.MasterTableView.GroupByExpressions.Clear();
            prospectGrid.MasterTableView.CurrentPageIndex = prospectGrid.MasterTableView.PageCount - 1;
            prospectGrid.Rebind();
        }
    }

but whenever I click on the EditLink hyperlink I get the Microsoft JScript runtime error: Object expected exception.

My default.aspx RadScriptManager code,

<telerik:RadScriptManager runat="server" ID="RadScriptManager1">
        <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 Path="~/Scripts/jquery.maphilight.min.js" />
            <asp:ScriptReference Path="~/Scripts/maphilight.js" />
        </Scripts>
    </telerik:RadScriptManager>



any help will be appreciated.
Mira
Telerik team
 answered on 08 Jul 2011
1 answer
43 views
In firefox, pressing backspace with in a delayfiltered filter box causes a postback after the delay. in IE8 and chrome it doesn't.

Full steps
1) Go to This rad grid demo page
2) put '2' in the order id column and wait for 4 seconds. The page reloads with the new filter (no results, but it doesn't matter what the text is).
3) Click on the field so that the cursor is to the right of the text.
4) Press backspace and wait for 4 seconds.
5-firefox) grid postbacks and updates as I expect it should.
5-ie-or-chrome) grid doesn't postback. Pressing enter does the postback (almost a valid workaround).

I think it should do the post back, but most of all I think it should be consistent.

Greg.
Tsvetoslav
Telerik team
 answered on 08 Jul 2011
3 answers
70 views
Hi all,

I've just started using the Telerik controls and I'm looking for some advice on how to achieve the requirement below.

I'd like the user to be able to choose a 'Create' option from a context menu on a tree view node.

On selecting this option, I'd like to display a Telerik Window to enable the user to create a new record. If this is too difficult, I'm happy for this to be some other UI element and I'm open to suggestion here.

On saving the record, I'd like to add the newly created item into the tree node.

1. Are there any code samples on how to open up a Window or form from a context menu item?

2. I'm trying to figure out the code that's needed to add items into the treeview and I'm following the article beneath.

http://www.telerik.com/help/aspnet-ajax/treeview-general-add-node-in-edit-mode-by-default.html

When I add the following javascript into my page, I get the following error when loading the page.

function HighlightNode(value) {
    var tree = $find("<%= RadTreeView1.ClientID %>");
    var node = tree.findNodeByValue(value);
    if (node != null) {
        node.startEdit();
    }
}


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I’m not sure if this is relevant but I've added a RadAjaxManager onto my page and am using the code beneath in the AddNode method.
Dim script As String = "HighlightNode(""" + newNode.Value + """)"
RadAjaxManager1.ResponseScripts.Add(script)

Any help or guidance would be much appreciated.

Tim
Tim
Top achievements
Rank 1
 answered on 08 Jul 2011
9 answers
235 views
Is it possible to open the RadGrid Popup Edit window manually? I would like to open it when clicking the update button so I can capture additional information from the user. 
William
Top achievements
Rank 1
 answered on 08 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?