如何在广告字符串中获取 asp:label 的值?



这听起来可能很奇怪,但这是我能做我需要做的事情的唯一方法,所以这里是:

我有:

<asp:Label ID="LabelStoreNumber" runat="server"></asp:Label> 

在.aspx页面上。 我想使用以下值: 稍后在广告文件中的 ASP 页中LabelStoreNumber.Text字符串。 广告行如下所示:

<asp:AdRotator ID="AdRotator1" runat="server"  Height="150" Width ="200" 
AdvertisementFile="<value of LabelStorNumber.Text>/PIC_List/PicList.xml"/> 

目标是任何访问此页面的人都将自动被定向到他们的商店编号 PicList.xml 目录。

我尝试过但没有成功:

<asp:AdRotator ID="AdRotator2" runat="server"  Height="150" Width ="200" 
AdvertisementFile="document.getElementById('<%=LabelStoreNumber.ClientID%>')
.innerText;/Alets/PIC_List/PicList1.xml"/> 

我最大的问题是我看不到实际返回的内容,所以我不确定我是否接近。

任何帮助都非常感谢!

不能使用客户端代码设置服务器端 AdRotator 控件的属性。相反,您应该在服务器端的页面代码隐藏文件中设置AdvertisementFile属性。例如,看起来像这样(例如Page_Load()(:

AdRotator2.AdvertisementFile = LabelStoreNumber.Text + "/PIC_List/PicList.xml";

最新更新