评估和演示脚本服务器端控件的ID属性? [英] Eval script for server side control's ID property?

查看:148
本文介绍了评估和演示脚本服务器端控件的ID属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下评估和演示脚本设置ID属性会导致错误。
错误信息:服务器标签不规范

Using the following Eval script for setting ID property causes error. Error message: the server tag is not well formed.

 <asp:Panel runat="server" ID="<%# Eval("RENTER_ID") %>" Visible="false">

即使ID属性替换与'生成错误。
在使用'',其错误消息

Even replacing "" with '' of ID property generates error. While using '', its error message

控件的ID属性只能使用标签的ID属性和一个简单的值设置示例:&LT; ASP:按钮=服务器ID =Button1的/ &GT;

"The ID property of a control can only be set using the ID attribute in the tag and a simple value. Example: <asp:Button runat="server" id="Button1" />"

任何想法解决这个?

推荐答案

您不能这样做。

你为什么需要?如果是这样,你可以在某些时候引用它,你可以通过属性的 ClientID的

Why do you need to? If it's so you can reference it at some point, you can access the client-side id via the property ClientID.

例如,要求:

<asp:Repeater runat="server" ID="repFoo">
    <ItemTemplate>
        <asp:Panel runat="server" ID="pnlFoo">
            <input type = "button"
                onclick = "alert('<%# Container.FindControl("pnlFoo").ClientID %>');"
                value   = "click to get id for <%# Container.ItemIndex %>" />
        </asp:Panel>
    </ItemTemplate>
</asp:Repeater>

这篇关于评估和演示脚本服务器端控件的ID属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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