我有一个页面parent.aspx
,其中包含一个用户控件csForm.ascx
。这个用户控件只是一个简单的表单,最后有一个发送按钮。我还使用Modal Popup Extender
中的AjaxToolKit
来显示表单。
Parent.aspx
<asp:ScriptManager runat="server" ID="scmg" />
<ajaxToolkit:ModalPopupExtender ID="mdlPopup" runat="server"
TargetControlID="btnCS" PopupControlID="csForm$pnlPopup"
BackgroundCssClass="modalBackground" OkControlID="csForm$btnSend"
CancelControlID="csForm$imgBtnClose" PopupDragHandleControlID="csForm$pnlPopup"
Drag="true" DropShadow="true" />
csForm.ascx.cs
protected void btnSend_Click(object sender, EventArgs e)
{
sendEmail(); //this gets automatically called when parent page is loaded.
}
我遇到的问题是在加载parent.aspx页面时会自动调用sendEmail()
。有办法阻止吗?我只想在点击Send
按钮时调用它。
答案 0 :(得分:0)
protected void btnSend_Click(object sender, EventArgs e)
{
if(IsPostBack)
{
sendEmail(); //this gets automatically called when parent page is loaded.
}
}
这不是正确的解决方案,但会解决这个问题。