引子:在编写程序的过程中,我们是不是有碰到这样的情况呢?
控件位于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

使用方式:
一、注册控件
<%@ 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一个小小的实用控件。                                &nbsp;<asp:TextBox ID="txtPageContent" runat="server" TextMode="multiLine" Width="96%"
 8一个小小的实用控件。                                    Text='<%# DataBinder.Eval(Container.DataItem,"PageContent") %>' />
 9一个小小的实用控件。
10>


没什么技术可言,不知道大家平时遇到这种情况是如何处理的。欢迎大家讨论

相关文章:

  • 2021-11-30
  • 2021-09-21
  • 2021-07-16
  • 2022-02-16
  • 2021-11-14
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-09-10
  • 2022-12-23
  • 2021-09-26
  • 2021-10-07
  • 2022-02-06
  • 2022-12-23
相关资源
相似解决方案