<脚本> ...< / SCRIPT>内Repeater控件code没有出现在源$ C ​​$ C页面上呈现 [英] <script>...</script> inside a repeater control code not showing up in the source code on page render

查看:99
本文介绍了<脚本> ...< / SCRIPT>内Repeater控件code没有出现在源$ C ​​$ C页面上呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中继器控制,其中的<%#DataBinder.Eval的(的Container.DataItem,显示)%>部分显示不出来。该显示卖场设置为code如下:

  item.Display =<脚本类型=文/ JavaScript的'> AudioPlayer.embed('ffcedea7-
4822-465f-85b6-89924f7b81fa',{音效档:http://s3.amazonaws.com/blah/af8g7fd3-1793
-4b5e-92b7-9d11ad1cc19c.mp3'});&下; /脚本>中;

在页面加载,音频嵌入文件没有显示出来。在code甚至没有在源代码中出现。如果我结束脚本标签后面添加一个随机字符串,随机字符串会显示出来。

  item.Display =<脚本类型=文/ JavaScript的'> AudioPlayer.embed('ffcedea7-4822-4
65F-85b6-89924f7b81fa',{音效档:http://s3.amazonaws.com/blah/af8g7fd3-1793-4b
5E-92b7-9d11ad1cc19c.mp3'});< / SCRIPT>这是随机字符串;

所以,在页面的源代码就会产生这是随机字符串,而不是剧本的部分。

有谁知道是什么原因造成这个问题以及如何修复?谢谢!

编辑:这里是中继code:

 < ASP:直放站ID =repeaterAddable=服务器>
    <&ItemTemplate中GT;
        < D​​IV CLASS =背景的白色>
            < D​​IV的风格=填充:15px的;>
                <表样式=宽度:100%CELLSPACING =5>
                    &所述; TR>
                        < TD合并单元格=3ALIGN =右>
                            包括这个? <输入类型=复选框NAME =包括<%#DataBinder.Eval的(的Container.DataItem,指数)%GT; />
                        < / TD>
                    < / TR>
                    &所述; TR>
                        < TD风格=宽度:30%; VALIGN =顶>                        < / TD>
                        < TD风格=宽度:30%; VALIGN =顶>
                            < D​​IV CLASS =媒体>                                <%#DataBinder.Eval的(的Container.DataItem,显示)%GT;                            < / DIV>
                        < / TD>
                        < TD风格=宽度:30%; VALIGN =顶>                        < / TD>
                    < / TR>
                < /表>
            < / DIV>
        < / DIV>
        < BR />
    < / ItemTemplate中>
< / ASP:直放站>


解决方案

也许你有你的页面上的某些安全设置或webconfig ...

我试图重现你的情况在一个全新的页面,但实际工作。

 大众A级
{
    公共字符串显示{搞定;组; }
}保护无效的Page_Load(对象发件人,EventArgs的发送)
{
    VAR名单=新名单,LT; A>();    VAR一个=新的A();
    a.Display =<脚本>警报('你好')< / SCRIPT> S< BR />中;    list.Add(一);    rep.DataSource =清单;
    rep.DataBind();
}

和页面

 < ASP:直放站ID =代表=服务器>
    <&ItemTemplate中GT;
        <%#DataBinder.Eval的(的Container.DataItem,显示)%GT;
    < / ItemTemplate中>
< / ASP:直放站>

或许你可以尝试设置显示 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆