为什么在Asp.net中,C#无法将控件设置为隐藏。 [英] Why in Asp.net , C# is not able to set control hidden.

查看:90
本文介绍了为什么在Asp.net中,C#无法将控件设置为隐藏。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我试图通过C#将控件设置为javascript和Html隐藏,请参阅下面的示例



Javascript(

Hi I ma trying to set the control hidden through C# as the javascript and Html does, see below example

Javascript (

controlId.style.display = 'block'

或HIde);



Html

or HIde);

Html

"style display:none"





所以我尝试使用C#代码但是没有成功,通过以下代码我在运行时失去了我的控制权。 />




so same thing i tried with C# code but did not get succeed, through below code I am loosing my control at run time.

html1.Attributes.Add("style", "display:none");




ButtonAssociateRules.Style["visibility"] = "hidden";





此代码完全删除了我的控件形成运行页面,我不想要因为我的javascipt在一段时间后使用该控件,并且我得到null,因为C#删除了该控件,我在运行时看到了源代码。





请帮忙。



this code completely removes my control form the running page, That I don't want because my javascipt is using that control after some time, and I am getting null, because C# removed that control, I have seen the source code at run time.


Please help.

推荐答案

你可以找到很多关于这个主题的文章。例如,此链接对您完全有用:

在ASP.Net中隐藏和显示控件
[ ^ ]
You can find many articles around this topic. For instance this link is completly helpful to you:
Hide and show control in ASP.Net
[^]


如果我理解正确,你试图隐藏控制权服务器代码,然后在某个时间点,您可以访问它的客户端。如果是这样,试试这个:

If i understood you correctly, You are trying to hide control at Server code and then at some point of time you are suppose to access it client side. If so, try this one:
your_control.Style.Add("display", "none");



请记住,这将在您的页面上呈现控制(不删除),因此它也可以在客户端提供。例如,如果它是 div 元素,你可以修改它的html,即使它不可见


Remember,this will render control at your page(Not remove), so it will be available at client side also.E.g. if its div element,you can modify its html even its not visible to you


(document).ready(function(){
/// //// ///////////
(document).ready(function () { //////////////////


这篇关于为什么在Asp.net中,C#无法将控件设置为隐藏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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