开发者

Calling jquery modal from code behind event in asp.net webform using MVP

i have a aspx page with a Login button. I want to, in case password does not match, to show a jquery modal window. Basically when the user click on an asp:button i call the Presenter's method (MVP) from my code-behind and i return either true or false. If it's false, i want to call this jquery modal window... i've been trying with some jquery plugins but it's not working. i am fairly new to jquery. maybe it's easy but it seem开发者_如何学编程s crazy to me. I've seen a lot of samples but all of them wait for the click action to open up. Basically i have to wait for a response from my code in order to trigger this.

void btnSubmit_click(sender, e)
{
if presenter.Login(x,y)
Response.Redirect(the page);
else
jquery modal window
}

Does anyone have an idea on how to achieve this? Thank you


If I am understanding correctly, here is a quick and dirty that should get you pointed in the right direction. Try adding an empty label on the page (with the viewstate disabled) where you can render HTML. Use this label to render the JavaScript to open your JQuery modal pop-up when you need to.

This may look something like:

void btnSubmit_click(sender, e)
{
  if presenter.Login(x,y)
     Response.Redirect(the page);
   else
     MyHTMLLabel.InnerHTML = "<script type=\"text/Javascript\">";
     MyHTMLLabel.InnerHTML += "$(document).ready(function () { ";
     MyHTMLLabel.InnerHTML += "alert('HERE YOU CALL THE FUNCTION TO OPEN YOUR WINDOW');";
     MyHTMLLabel.InnerHTML += "});</script>"
}

Anyway... that's a pretty rough example but it should give you a start.


What do you mean: 'jquery modal window'? You show code in the server. You may generated a response that contains as its onload action a jquery dialog box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜