CSS 和 Asp:按钮冲突
我正在处理网页,有时我需要禁用 asp:button。
此页面使用具有以下类的 css 文件:
.pagerLinkDisabled
{
display: none;
}
因此,每次我将按钮设置为禁用时,.net 都会使用 class="pagerLinkDisabled"
呈现它,并且不会显示该按钮...
在页面加载时,我尝试过这个:
myButton.Enabled=false;
myButton.Style.Add("display","static");
如何在不更改 css 文件的情况下解决此问题?
谢谢:)
编辑:
澄清一下:
按钮正在呈现,但当启用设置为 false 时,框架会将 class="pagerLinkDisabled" 添加到输入标记。
此类是在我无法更改的 css 文件中定义的。
Edit2:
我的按钮定义如下:
<asp:Button runat="server" ID="myButton" Text="mytext" Enabled="false" />
正在呈现的 html 是:
<input type="submit" name="ctl00$ContentPlaceHolder$ctl00$myButton" value="mytext" id="ctl00_ContentPlaceHolder_ctl00_myButton" class="pagerLinkDisabled" />
I am working on a webpage and at some point I need to disable a asp:button.
This page uses a css file that has the following class:
.pagerLinkDisabled
{
display: none;
}
So every time I set a button to disabled .net renders it with class="pagerLinkDisabled"
and the button is not displayed...
At pageload I tried this:
myButton.Enabled=false;
myButton.Style.Add("display","static");
How can I work around this problem without changing the css file?
Thanks :)
Edit:
To clarify:
The button is being rendered but when enabled is set to false the framework is adding class="pagerLinkDisabled" to the input tag.
This class is defined at a css file that I cannot change.
Edit2:
My button is defined as such:
<asp:Button runat="server" ID="myButton" Text="mytext" Enabled="false" />
The html that is being rendered is:
<input type="submit" name="ctl00$ContentPlaceHolder$ctl00$myButton" value="mytext" id="ctl00_ContentPlaceHolder_ctl00_myButton" class="pagerLinkDisabled" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
编辑 这对我有用。
Edit This works for me.
我不确定,但尝试页面加载:
I am not sure but try at page load:
您不能只编辑 HTML 源 以便按钮不使用该类吗?
或者它是在 HTML 中定义的更高级别? 例如在 BODY 标签处。
Can you not just edit the HTML Source so that the button does not use that class?
Or is it defines at a higher level within with HTML? e.g. At the BODY tag.
为什么不直接更改按钮上的类名称呢?
Why not just change the class name on the button?
你有没有尝试过这样的事情:
Have you tried something like this: