禁用Asp.Net自动命名 [英] Disabling Asp.Net Auto Naming

查看:98
本文介绍了禁用Asp.Net自动命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来禁用ASP.Net自动命名?

Is there a way to disable the ASP.Net auto-naming?

例如:当我有一个母版,而不是被命名坐在里面我的网页上控制

For instance: When I have a control on my page that sits inside a masterpage instead of being named

theLabel

它重命名为

ctl00_ContentPlaceHolder1_clist0_rptSelected_ctl05_theLabel

这是我不希望的行为。

推荐答案

如果你足够幸运,能够针对ASP.NET 4.0 ...

If you're lucky enough to be able to target ASP.NET 4.0...

在你的页面指令,设定的ClientIDMode =静态。这将发出的ID正是因为你有他们在你的控制。

In your page directive, set ClientIDMOde="Static". This will emit ID's exactly as you have them in your controls.

所以,如果您有:

<asp:Label ID="example" runat="server" />

它会发出这种清洁ID:

It will emit this clean ID:

<span id="example">something...</span>

这篇关于禁用Asp.Net自动命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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