简体   繁体   English

在我改变javascript中的div属性之前,如何在c#.net中获取div显示属性

[英]How to get the div display property in c#.net before i changed div property in javascript

i Have one div in my default web page . 我在默认网页中有一个div。 The div style display none, that time in page load event i have to get the status none, but the div status changed in javascript function based on dropdown selection that i dosenot get the none status always show "" status, my code is div样式显示无,在页面加载事件中的时间我必须得到状态none,但是在javascript函数中根据下拉选择更改了div状态,我得到了无状态总是显示“”状态,我的代码是

aspx page aspx页面

 <div id="Div1" runat="server" clientidmode="Static" style="display: none;">

pageload event pageload事件

     string Display1 = "";
    Display1 = Div1.Style["display"]; (working fine)( get the display1 value=none)

when i button click show the div like that in c# code 当我按下按钮时,在c#代码中显示div

    Div1.Style.Add("display", "");(now show the div it is correct)

Dropdown Changed fire javascript function code Dropdown更改了fire javascript功能代码

    document.getElementById('Div1').style.display = 'none'; (after change dropdown Hide the div after pageload i got Display1 value="")

After changed javascript function i doenot get the none status in page load 更改javascript函数后,我在doenot中获取页面加载中的无状态

DIV is a HTMLGenericalControl in ASP.Net and any changes you make it in the client to its style or attributes, i dont think it will be posted back to server, instead you can track the changes on a Hidden control which has runat server attribute to true and capture the changes. DIV是ASP.Net中的HTMLGenericalControl以及你在客户端根据其样式或属性进行的任何更改,我认为它不会发布回服务器,而是可以跟踪具有runat服务器属性的Hidden控件的更改为true并捕获更改。

let me know if it helps 让我知道它是否有帮助

you can use like this it's below 你可以这样使用它在下面

<script type="text/javascript">
        $(function () {
            $("#lnkCompany").click(function () {
                if ($("#dvClientReg").css('display') == 'block') {
                    $("#dvClientReg").css('display', 'none');
                }
                if ($("#dvCompanyReg").css('display') == 'none') {
                    $("#dvCompanyReg").css('display', 'block');

                }
            });

  });
</script>

i think this will help you 我想这会对你有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在屏幕上显示函数的输出 <div> 在c#.net - Display the output of a function in a <div> in c#.net 如何使用C#.Net中的LDAP获取Windows活动目录中组织单位的streetaddress属性 - How to get streetaddress property of an organizational unit in windows active directory with LDAP in C#.Net 如何在 c#.net 中创建 xml 文档作为属性 - How to create xml document as a property in c#.net C#.Net 2010中GroupBox的UseMnemonic属性 - UseMnemonic property of a GroupBox in C#.Net 2010 在c#.net中更改keep alive属性 - Changing the keep alive property in c#.net 覆盖列表框c#.net中的itemsource属性 - override itemsource property in listbox c#.net 如何在C#.Net中使用Customer中的属性Orders访问Order类属性 - How to access Order class property using property Orders in Customer in C#.Net 如何从 C#.Net 核心中的任何类型的 object 结构(使用递归方法?)获取 JSON 中的属性及其值的平面列表? - How to get flat list of property and its values in JSON from any kind of object structure (using recursive method?) in C#.Net core? 如何在C#.net中获取JavaScript确认弹出窗口值 - How to get javascript confirm popup value in c#.net C#.NET - 如何使用typeof()来继承? - C#.NET - How can I get typeof() to work with inheritance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM