2013-03-05 63 views
1

我在我的asp.net应用程序中有一个ModalPopup窗口,我想要在单击Listview控件项目时显示该窗口。ModalPopup div不显示

<div id="ModalPopup" style="visibility:hidden" runat="server"> 
    <div style="position: absolute; width: 100%; height: 100%; z-index: 10002; background-color: Gray; filter: alpha(opacity=70); opacity: 0.7;"> 
    &nbsp; 
    </div> 
    <table style="position: absolute; width: 100%; height: 100%; z-index: 10003;"> 
    <tr> 
     <td align="center" valign="middle"> 
     <div style="color: Black; font-weight: bolder; background-color: White; padding: 15px; width: 200px;"> 
      <asp:Image ID="Image4" runat="server" ImageUrl="~/Images/ajax-loader.gif" />...Processing.... 
     </div> 
     </td> 
    </tr> 
    </table> 
    </div> 

然而,在我RadListView1_SelectedIndexChanged事件,我的代码是:ModalPopup.Attributes.Add("style", "visibility:visible");但模式弹出不显示。

我怎么能当选择ListView项显示呢?

+0

使用回传本会耗尽你的任何类似的可用性的应用。帮你一个忙,jQuery/JavaScript的模态弹出。 – Syddraf 2013-03-05 23:40:09

回答

1

由于您已经定义了ModalPopup DIV作为服务器控件(如runat=server你要决定是否要显示它或代码隐藏不- 只需使用Visible属性.. 。

<div id="ModalPopup" Visible="false" runat="server"> 
    .... 
</div> 

,并在代码的RadListView1_SelectedIndexChanged事件背后只是改变可见的真:

protected void RadListView1_SelectedIndexChanged() 
{ 
    ModalPopup.Visible = true; 
} 

,如果你坚持要改变能见度属性本身,你可以使用RegisterStartupScript这样的:

protected void RadListView1_SelectedIndexChanged() 
{ 
    ClientScript.RegisterStartupScript(this.GetType(), "ShowPopup", "document.getElementById('" + ModalPopup.ClientID + "').style.visibility = 'visible';", true); 
} 
+0

这两者都没有工作:-( – Csharp 2013-03-06 13:41:42

+0

这似乎不太可能,请在原始问题中发布您的新更新代码,包括相关代码隐藏... – Blachshma 2013-03-06 13:44:01