【问题标题】:How to disable a div code behind in C#?如何在 C# 中禁用 div 代码?
【发布时间】:2013-07-11 20:35:14
【问题描述】:

我有一个 div,我通过 Page.ClientScript.RegisterStartupScript 从后面的代码中调用它 另一个div在这个div里面style="display: none;当我在后面的代码中调用主div时是否可以启用第二个div?

这是我的代码- Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenNewWindow", "<script type='text/javascript'>$(function() { $('#MainDiv').dialog('open'); })</script>");

【问题讨论】:

  • 如果你可以调用第一个,那为什么不能调用第二个呢??
  • 第二个在第一个里面,我需要将第二个和第一个一起调用,并将样式更改为display:block
  • 那为什么没有发生呢???说$('#MainDiv > :first-child').show();
  • 为什么不用对话框的open事件来显示内部的div呢?
  • @Pitchai Pazhani- 我可以打开内部 div,但是如何更改样式?

标签: c# javascript jquery asp.net ajax


【解决方案1】:

我这样称呼第二个div的类名-

Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenNewWindow", "<script type='text/javascript'>$(function() { $('#MainDiv').dialog('open'); });$('.second-div-class').show();</script>");

【讨论】:

    【解决方案2】:
    put these attributes in div runat="server"  and an id="a_name"
    Declare Your div like following
    
    <div runat="server" id="dv">
    your contents
    </div>
    
    call the dv from Code behind and then do with that dv whatever you want 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-13
      • 1970-01-01
      相关资源
      最近更新 更多