Problem using Telerik.Web.SkinRegistrar.GetWebResourceUrl in usercontrol

4 posts, 0 answers
  1. ericc34
    ericc34 avatar
    91 posts
    Member since:
    Jul 2006

    Posted 19 Jan 2012 Link to this post

    My problem is when i try to use Telerik.Web.SkinRegistrar.GetWebResourceUrl like this :

    <

     

     

    asp:ImageButton ID="btnEditExternalCollaborator" runat="server" ImageUrl='<%# Telerik.Web.SkinRegistrar.GetWebResourceUrl(Me, GetType(RadGrid), "Telerik.Web.UI.Skins.Office2007.Grid.Edit.gif") %>' ToolTip="btnEditExternalCollaboratorTooltip" />


    in an usercontrol. Error is :

    BC30311: Une valeur de type 'ASP.subject_psi_uccollaborators_ascx' ne peut pas être convertie en 'System.Web.UI.Page'.

    How I can do in userontrol ?
  2. Abhishek
    Abhishek avatar
    45 posts
    Member since:
    Jul 2012

    Posted 20 Jan 2012 Link to this post

    Hello  erric34,

    I came up with one solution for you, I have assign ImageURL in Itemdatabound inside the usercontrol itself here i am posting you code please have one look.

    ASPX:
    <telerik:RadGrid ID="rgTesting" runat="server" GridLines="None" AllowPaging="True"
               CssClass="RadGrid" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="true" OnItemDataBound="rgTesting_OnItemDataBound"           
               DataSourceID="Testfile">
               <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="ID" EditMode="InPlace">
                   <Columns>
                       <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                       </telerik:GridEditCommandColumn>
                       <telerik:GridBoundColumn UniqueName="Name" HeaderText="Name" DataField="Name">
                       </telerik:GridBoundColumn>
                       <telerik:GridTemplateColumn>
                           <ItemTemplate>                           
                               <asp:ImageButton ID="btnEditExternalCollaborator" CommandName="edit" runat="server"  ToolTip="btnEditExternalCollaboratorTooltip" />
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>                   
                   </Columns>               
               </MasterTableView>
           </telerik:RadGrid>
           <asp:XmlDataSource ID="Testfile" runat="server" DataFile="~/XMLFiles/RadCombo.xml">
           </asp:XmlDataSource>

    .CS :
    public partial class TestingUserControl : System.Web.UI.UserControl
        {
            public Page ME=new Page();
     
            protected void Page_Load(object sender, EventArgs e)
            {          
            }
     
            protected void rgTesting_OnItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is GridDataItem)
                {
                    GridDataItem DataBound=(GridDataItem)e.Item;
                    ImageButton btnEditExternalCollaborator = (ImageButton)DataBound.FindControl("btnEditExternalCollaborator");
                    btnEditExternalCollaborator.ImageUrl = Telerik.Web.SkinRegistrar.GetWebResourceUrl(ME, typeof(Telerik.Web.UI.RadGrid), "Telerik.Web.UI.Skins.Office2007.Grid.Edit.gif");
                }
            }
        }

    I think it works in your scenario also.

    Thanks,
    Abhishek K
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ericc34
    ericc34 avatar
    91 posts
    Member since:
    Jul 2006

    Posted 20 Jan 2012 Link to this post

    Thanks

    But I have a little problem with your code on this line

    btnEditExternalCollaborator.ImageUrl = Telerik.Web.SkinRegistrar.GetWebResourceUrl(ME, typeof(Telerik.Web.UI.RadGrid), "Telerik.Web.UI.Skins.Office2007.Grid.Edit.gif");

    I receive this error message RadGrid is a type in UI and cannot be used as an expression. I'm in VB not C

  5. Abhishek
    Abhishek avatar
    45 posts
    Member since:
    Jul 2012

    Posted 21 Jan 2012 Link to this post

    Hello ercc34,
    Actually i don't know much about VB. Please use this link http://www.developerfusion.com/tools/convert/csharp-to-vb/
     for conversion from c# code to vb. I think it may solve your problem. Else post your code i try my best.

    Converted Code:
    Protected Sub rgTesting_OnItemDataBound(sender As Object, e As GridItemEventArgs)
        If TypeOf e.Item Is GridDataItem Then
            Dim DataBound As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim btnEditExternalCollaborator As ImageButton = DirectCast(DataBound.FindControl("btnEditExternalCollaborator"), ImageButton)
            btnEditExternalCollaborator.ImageUrl = Telerik.Web.SkinRegistrar.GetWebResourceUrl([ME], GetType(Telerik.Web.UI.RadGrid), "Telerik.Web.UI.Skins.Office2007.Grid.Edit.gif")
        End If
    End Sub

    Try out this, let me know if any issue.

    Thanks,
    Abhishek K
Back to Top