This is a migrated thread and some comments may be shown as answers.

Rotator Image Folder

1 Answer 58 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Mazdak
Top achievements
Rank 1
Mazdak asked on 16 Jun 2011, 01:45 AM
Hi.

I have some folders in my solution such as UserAccount, Admin, etc.
I bind rotator to XmlDataSource, but when I'm not in site root (ex: MySiteName/Admin/Default.aspx) rotator does not work.
Here is the code:

 

 

 

 

<telerik:RadRotator ID="RadRotator1" runat="server" Height="150px"
  ItemHeight="150px" ItemWidth="600px" ScrollDirection="Up" ScrollDuration="4000" 
  Width="600px" DataSourceID="XmlDataSource1">
  <ItemTemplate>
    <div>
      <a href="<%# XPath("href") %>">
        <img src="IMG/<%# XPath("filename") %>" alt="IMG/<%# XPath("filename") %>" style="border: 0px;"/>
      </a>
    </div>
  </ItemTemplate>
</telerik:RadRotator>
</div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" 
  DataFile="~/Banners.xml" ></asp:XmlDataSource>

 

 

 

1 Answer, 1 is accepted

Sort by
0
Mazdak
Top achievements
Rank 1
answered on 16 Jun 2011, 11:19 AM
Hi there.
I solve problem:

In C#
public string PATH = "";
protected void Page_Load(object sender, EventArgs e)
{
    string _path = this.BaseUrl + "IMG/";
    this.PATH = _path;
}
 
public string BaseUrl
{
    get
    {
        string url = this.Request.ApplicationPath;
        if (url.EndsWith("/"))
            return url;
        else
            return url + "/";
    }
}

ASPX Page
<telerik:RadRotator ID="RadRotator1" runat="server" Height="150px"
  ItemHeight="150px" ItemWidth="600px" ScrollDirection="Up" ScrollDuration="4000"
  Width="600px" DataSourceID="XmlDataSource1">
  <ItemTemplate>
    <div>
      <a href="<%# XPath("href") %>">
        <img src="<%# PATH + XPath("filename") %>" alt="<%# PATH + XPath("filename") %>" style="border: 0px;"/>
 
      </a>
    </div>
  </ItemTemplate>
</telerik:RadRotator>

Tags
Rotator
Asked by
Mazdak
Top achievements
Rank 1
Answers by
Mazdak
Top achievements
Rank 1
Share this question
or