&LT;脚本&GT; ...&LT; / SCRIPT&GT;内Repeater控件code没有出现在源$ C $ C页面上呈现 [英] <script>...</script> inside a repeater control code not showing up in the source code on page render
问题描述
我有一个中继器控制,其中的&lt;%#DataBinder.Eval的(的Container.DataItem,显示)%>部分显示不出来。该显示卖场设置为code如下:
item.Display =&LT;脚本类型=文/ JavaScript的'&GT; AudioPlayer.embed('ffcedea7-
4822-465f-85b6-89924f7b81fa',{音效档:http://s3.amazonaws.com/blah/af8g7fd3-1793
-4b5e-92b7-9d11ad1cc19c.mp3'});&下; /脚本&gt;中;
在页面加载,音频嵌入文件没有显示出来。在code甚至没有在源代码中出现。如果我结束脚本标签后面添加一个随机字符串,随机字符串会显示出来。
item.Display =&LT;脚本类型=文/ JavaScript的'&GT; AudioPlayer.embed('ffcedea7-4822-4
65F-85b6-89924f7b81fa',{音效档:http://s3.amazonaws.com/blah/af8g7fd3-1793-4b
5E-92b7-9d11ad1cc19c.mp3'});&LT; / SCRIPT&GT;这是随机字符串;
所以,在页面的源代码就会产生这是随机字符串,而不是剧本的部分。
有谁知道是什么原因造成这个问题以及如何修复?谢谢!
编辑:这里是中继code:
&LT; ASP:直放站ID =repeaterAddable=服务器&GT;
&LT;&ItemTemplate中GT;
&LT; DIV CLASS =背景的白色&GT;
&LT; DIV的风格=填充:15px的;&GT;
&LT;表样式=宽度:100%CELLSPACING =5&GT;
&所述; TR&GT;
&LT; TD合并单元格=3ALIGN =右&GT;
包括这个? &LT;输入类型=复选框NAME =包括&LT;%#DataBinder.Eval的(的Container.DataItem,指数)%GT; /&GT;
&LT; / TD&GT;
&LT; / TR&GT;
&所述; TR&GT;
&LT; TD风格=宽度:30%; VALIGN =顶&GT; &LT; / TD&GT;
&LT; TD风格=宽度:30%; VALIGN =顶&GT;
&LT; DIV CLASS =媒体&GT; &LT;%#DataBinder.Eval的(的Container.DataItem,显示)%GT; &LT; / DIV&GT;
&LT; / TD&GT;
&LT; TD风格=宽度:30%; VALIGN =顶&GT; &LT; / TD&GT;
&LT; / TR&GT;
&LT; /表&gt;
&LT; / DIV&GT;
&LT; / DIV&GT;
&LT; BR /&GT;
&LT; / ItemTemplate中&GT;
&LT; / ASP:直放站&GT;
也许你有你的页面上的某些安全设置或webconfig ...
我试图重现你的情况在一个全新的页面,但实际工作。
大众A级
{
公共字符串显示{搞定;组; }
}保护无效的Page_Load(对象发件人,EventArgs的发送)
{
VAR名单=新名单,LT; A&GT;(); VAR一个=新的A();
a.Display =&LT;脚本&GT;警报('你好')&LT; / SCRIPT&GT; S&LT; BR /&gt;中; list.Add(一); rep.DataSource =清单;
rep.DataBind();
}
和页面
&LT; ASP:直放站ID =代表=服务器&GT;
&LT;&ItemTemplate中GT;
&LT;%#DataBinder.Eval的(的Container.DataItem,显示)%GT;
&LT; / ItemTemplate中&GT;
&LT; / ASP:直放站&GT;
或许你可以尝试设置显示
与 HttpUtility.UrlEn code
和<得到它code> HttpUtility.UrlDe code ...
I have a repeater control where the <%#DataBinder.Eval(Container.DataItem, "Display")%> part doesn't show up. The code that the "Display" stores is set as follows:
item.Display = "<script type='text/javascript'>AudioPlayer.embed('ffcedea7-
4822-465f-85b6-89924f7b81fa', {soundFile: 'http://s3.amazonaws.com/blah/af8g7fd3-1793
-4b5e-92b7-9d11ad1cc19c.mp3'});</script>";
After the page load, the audio embed file doesn't show up. The code doesn't even show up in the source. If I add a random string after the ending script tag, that random string will show up.
item.Display = "<script type='text/javascript'>AudioPlayer.embed('ffcedea7-4822-4
65f-85b6-89924f7b81fa', {soundFile: 'http://s3.amazonaws.com/blah/af8g7fd3-1793-4b
5e-92b7-9d11ad1cc19c.mp3'});</script> THIS IS THE RANDOM STRING";
So, on the page source it will have " THIS IS THE RANDOM STRING" but not the script part.
Does anyone know what is causing this issue and how it can be fixed? Thanks!
Edit: Here is the repeater code:
<asp:Repeater ID="repeaterAddable" runat="server">
<ItemTemplate>
<div class="background-white">
<div style="padding: 15px;">
<table style="width: 100%" cellspacing="5">
<tr>
<td colspan="3" align="right">
Include this? <input type="checkbox" name="include<%#DataBinder.Eval(Container.DataItem, "Index")%>" />
</td>
</tr>
<tr>
<td style="width: 30%;" valign="top">
</td>
<td style="width: 30%;" valign="top">
<div class="media">
<%#DataBinder.Eval(Container.DataItem, "Display")%>
</div>
</td>
<td style="width: 30%;" valign="top">
</td>
</tr>
</table>
</div>
</div>
<br />
</ItemTemplate>
</asp:Repeater>
Maybe you have some safe settings on your page or webconfig...
I tried to reproduce your situation in a brand new page, but it actually worked.
public class A
{
public string Display { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
var list = new List<A>();
var a = new A();
a.Display = "<script>alert('hi')</script>S<br/>";
list.Add(a);
rep.DataSource = list;
rep.DataBind();
}
And in the page
<asp:Repeater ID="rep" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Display") %>
</ItemTemplate>
</asp:Repeater>
Perhaps you can try to set the Display
with HttpUtility.UrlEncode
and get it with HttpUtility.UrlDecode
...
这篇关于&LT;脚本&GT; ...&LT; / SCRIPT&GT;内Repeater控件code没有出现在源$ C $ C页面上呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!