我有一个按钮,Linkbutton和一个ModalPopup。
如果我点击button1,我需要自动点击第二个按钮并启动ModalPopup。但它根本不会触发。
谁能说我哪里出错?
这是我的ModalPopup:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1"
PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="False"
CancelControlID="CancelButton" />
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none;
width: 300px;">
<asp:HyperLink ID="DownloadLink" runat="server" ForeColor="#0066FF">Download</asp:HyperLink>
<asp:Button ID="CancelButton" CssClass="btn-blue" runat="server" Text="Cancel" />
<asp:Button ID="button1" runat="server" Text="Select Image" Style="position: absolute;
left: 400px; top: 500px; z-index: 99;"/>
<asp:LinkButton ID="LinkButton1" OnClick="LinkButton1_Click" runat="server" Visible="true"
Style="position: absolute; left: 620px; top: 500px; z-index: 99;">Close</asp:LinkButton>
</asp:Panel>
<br />
</ContentTemplate>
</asp:UpdatePanel>
这是我的代码隐藏:
第一个按钮:
Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
Linkbutton1_Click(Nothing,Nothing)
End Sub
第二个按钮:
Protected Sub Linkbutton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Linkbutton1.Click
ModalPopupExtender1.Show
End Sub
答案 0 :(得分:1)
除非我缺少某些东西,否则您使用的方法似乎不必要地复杂化。只需创建一个打开对话框的方法,您就可以在任何地方调用它......
protected void LinkButton1_Click(object sender, EventArgs e)
{
//perform whatever logic you need
//open the dialog
ShowDialog();
}
protected void Button1_Click(object sender, EventArgs e)
{
//perform whatever logic you need
//open the dialog
ShowDialog();
}
private void ShowDialog()
{
ModalPopupExtender1.Show();
}
答案 1 :(得分:0)
试一试。对于第一个按钮内的代码,请单击。
Linkbutton1_Click(sender, New System.EventArgs())