在.NET项目的HTML标签的ClientID [英] HTML Tag ClientID in a .NET Project

查看:112
本文介绍了在.NET项目的HTML标签的ClientID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想在基于母版页,即一个aspx页面操作服务器上的HTML标签的属性。

If I want to manipulate an HTML tag's properties on the server within an aspx page based on a master page i.e.

<a href="#" runat="server" ID="myLink">My Link</a>

例如,得到链路不同级取决于当前页即

For example to give the link a different class depending on the current page i.e.

if (Path.GetFileName(Request.PhysicalPath) == "MyPage")
{
myLink.Attributes.Add("class","active");
}

.NET更改链接的东西的ID属性像

.NET changes the ID property of the link to something like

<a href="#" ID="ct100-foo-myLink">My Link</a>

有没有什么办法的发生和保持原来的ID停止这样?

Is there any way of stopping this from happening and keeping the original ID?

在此先感谢

推荐答案

AFAIK没有办法。

AFAIK there is no way.

有显示实际控制树,这是在这种情况下,母版化内容的控制。

It shows the actual control tree, which is in this case masterpage-content-control.

不过,如果你添加一个ID为母版(this.ID =无所谓),然后你会看到什么而不是ctl00(即控制指标0)。

However if you add an ID to the masterpage (this.ID = "whatever") then you will see "whatever" instead of ctl00 (which means control index 0).

这篇关于在.NET项目的HTML标签的ClientID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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