控件位于Repeater,DataList,DataGrid中,但是我们需要在脚本中引用这个控件的ClientID或者UniqueName,但这时用传统的<%# ctl.ClientID %>会说找不到此控件。
这时候我们需要一个小小的控件:我叫它:BindableLiteral
看代码:
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Web.UI.WebControls;
5
using System.ComponentModel;
6
using System.Web.UI;
7
8
namespace Limited.Controls
9
2
3
4
5
6
7
8
9
使用方式:
一、注册控件
<%@ Register Assembly="Controls" Namespace="Limited.Controls" TagPrefix="lm" %>
二、使用
1
<asp:Repeater ID="rptPageArticle" runat="server" OnItemCommand="rptPageArticle_ItemCommand">
2
<HeaderTemplate>
3
<div id="xToolbar" style="overflow: visible; width: 100%; display: none;">
4
</div>
5
</HeaderTemplate>
6
<ItemTemplate>
7
<asp:TextBox ID="txtPageContent" runat="server" TextMode="multiLine" Width="96%"
8
Text='<%# DataBinder.Eval(Container.DataItem,"PageContent") %>' />
9
10
>
2
3
4
5
6
7
8
9
10
没什么技术可言,不知道大家平时遇到这种情况是如何处理的。欢迎大家讨论。