如何在asp.net c中的转发器中动态绑定iframe [英] how to bind iframe dynamically in repeater in asp.net c#

查看:101
本文介绍了如何在asp.net c中的转发器中动态绑定iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请一些人告诉如何在asp.net c中的转发器控件中动态绑定iframe#
i使用转发器中的代码是

< iframe id =iframe1 src =<%#Eval(video)%> runat =serverwidth ='640'height ='390'>< / iframe>

和后面的代码是

Pls some one tell that how to bind iframe dynamically in repeater control in asp.net c#
i uses the code in repeater is
<iframe id="iframe1" src="<%#Eval("video") %>" runat="server" width='640' height='390'></iframe>
and the code behind is

protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       {
           repeter_bind();
       }
   }
   private void repeter_bind()
   {

           string sql = "select * from tbl_blog order by blog_ins_date desc ";
           cq.run_repeater(sql, repeter_blog);
        //   iframe1.Attributes["src"] =




   }







但在添加iframe之后转发器控制它显示服务器标签格式不正确。

请一些人告诉我如何在数据库的转发器控制中动态绑定iframe,并在列中显示视频的链接。 />
http://www.youtube.com/embed/oqhk3UEsK48



请一些人告诉我如何解决这个问题




but after adding iframe in repeater control it shows that server tag is not well formed.
Pls some one tell that how to bind iframe dynamically in repeater control from the database and in the colum ther is a link for the video.
http://www.youtube.com/embed/oqhk3UEsK48

Pls some one tell that how to solve this problem

推荐答案

而不是

src =<%#Eval(video)%>



尝试:

src =<%#Eval( ' 视频 ' )%>
Instead of
src="<%#Eval("video") %>"

Try:
src="<%#Eval('video') %>"


你可以这样做

步骤1.创建一个返回iframe的完整路径src属性的方法

You can do like that
Step 1. Create a method that return full path src attribute of iframe
public string GetUrl(string id)
        {
            // You can change the value of url as your own.
            return "../../abc/xyz.aspx?Id =" + id;
        }





步骤2.定义Ifranme并传递你的id以生成url。





Step 2. Define Ifranme and pass your id to generate url.

<iframe style=" width: 450px; height: 400px;" id="irm1" src='<%#GetUrl(Eval("Id").ToString()) %>' runat="server"></iframe>


这篇关于如何在asp.net c中的转发器中动态绑定iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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