我有一个模态div与一个不可见的按钮和iframe。iframe将用户带到外部站点(在那里他们可以输入付款)。然后,iframe被定向回我的网站,这样我就可以记录付款。如果支付不能正确处理并抛出异常,我希望按钮变得可见,并将iframe重定向到我的错误页面。我无法让按钮显示。
这就是Page_Load对于modal的样子。这个page_load发生在用户完成支付并被定向回站点之后。
protected void Page_Load(object sender, EventArgs e)
{
errorDirect.Visible = false;
try
{
//lots of code to process the payment
}
catch (Exception ex)
{
errorDirect.Visible = true;
Response.Redirect("ErrorPage.aspx");
}
这就是模态div的样子,只是一个iframe和一个按钮。
<div id="overlay" runat="server">
<iframe id="iframe" name="my-iframe" style="width: 850px; height: 700px;" frameborder="0" ></iframe>
<input type="button" id="errorDirect" Value="Back to Login Page" runat="server" onclick="parent.error()" />
</div>
本网站最初编写时没有情态动词,一些用户将需要继续使用该网站的旧版本。模态div的父类是唯一可以处理模态的类,这就是为什么按钮需要显示并在重定向的iframe之外。我想知道的是为什么我的按钮不可见,如果有什么我能做的来解决这个问题。注意:当我调试时,errorDirect的值。
我不确定它是否可以帮助,但试试这个:
protected void Page_Load(object sender, EventArgs e)
{
errorDirect.Visible = false;
try
{
//lots of code to process the payment
}
catch (Exception ex)
{
Application.Current.Dispatcher.Invoke( ()=> errorDirect.Visible = true);
Response.Redirect("ErrorPage.aspx");
}
}