如果符合某些条件,则在点击位于MasterPage上的Submit
按钮后显示一个精美的框。
场景,用户在密码文本框中输入默认密码“basic”,然后单击Submit
按钮,应触发精美框。
在后面的MasterPage代码中使用 hidden_link 与 Literal 一起尝试,以及 ScriptManager.RegisterClientScriptBlock ,但它无效。
在head标签内:
<script type="text/javascript">
$(document).ready(function () {
$('.editLogin').fancybox({
openEffect: 'none',
closeEffect: 'fade',
arrows: false,
maxWidth: 700,
maxHeight: 320,
type: "iframe",
href: redirectLink
})
});
身体:
<asp:Button ID="SubmitButton" runat="server" OnClick="SubmitButton_Click" Text="Submit" Width="65px" />
代码背后:
protected void SubmitButton_Click(object sender, EventArgs e)
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["editor"].ConnectionString);
con.Open();
string cmdStrCkApp = "Select count(*) from People Where Email='" + userTextBox.Text + "' AND Deleted='N' AND Approved='Y'";
SqlCommand CkApp = new SqlCommand(cmdStrCkApp, con);
int tempCA = Convert.ToInt32(CkApp.ExecuteScalar().ToString());
if (tempCA == 1)
{
if (password == "basic")
{
Session["ChangeLogin"] = pID;
string redirectTo = "/login/EditPassword.aspx";
ScriptManager.RegisterStartupScript(this, GetType(), "", "var redirectLink = " + redirectTo + " $('.editLogin').fancybox.trigger('click');", true);
}
else
{
Session["ChangeLogin"] = pID;
Response.Redirect("/myPage.aspx");
}
}
Response.Redirect(“/ login / EditPassword.aspx”)运行正常,但是,我们需要它在精美的框中打开以匹配网站的其余部分。