2013-03-05 64 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