用户控制静态名称选项? [英] User Control Static Name Option?

查看:124
本文介绍了用户控制静态名称选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一种方法强制asp网络用户控件(ASCX)使用静态的ID,这样它们就不会与所有的附加命名垃圾追加......但有没有办法做到同为名属性?具体而言,在这种情况下,对于DDL的? JQuery的需要一个特定的名字,我需要从这样停止.NET。

I know there is a way to force asp web user controls (ascx) to use static ID's so they don't get appended with all the appended naming garbage...but is there way to do the same for the"name" attribute? Specifically, in this case, for DDL's? JQuery needs a specific name and I need to stop .NET from doing this.

推荐答案

未在ASP.Net可能现在...我发现这个组合是一个可以接受的解决办法。

Not possible in ASP.Net for now ... I've found this combination to be an acceptable solution.

添加的ClientIDMode =静态来控制:

<asp:HiddenField ID="HiddenField1" runat="server" ClientIDMode="Static" />

使用jQuery,就文件准备好,在控制的name属性设置为id的值:

Using JQuery, on document ready, set the name attribute on the control to the value of its id:

$(document).ready(function () {

            // alert($("#HiddenField1").attr("name"));

            $("#HiddenField1").attr("name", "HiddenField1");

            // alert($("#HiddenField1").attr("name"));
        });

这篇关于用户控制静态名称选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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