i have my login in a fancybox and fancybox div is in a controller. problem is if click the button nothing happens event isnt fired. this is my controller.ascx
<div id="inline1" style="width:400px;">
<ul class="forms">
<li class="inputfield"><asp:TextBox ID="kullanıcı_adi" runat="server"></asp:TextBox></li>
</ul>
<ul>
<li><asp:TextBox ID="sifre" runat="server"></asp:TextBox></li>
</ul>
<ul>
<li>
<asp:Button ID="Button1" runat="server" Text="Giriş Yap"
onclick="Login_Authenticate" />
<asp:Button ID="Button2" runat="server" Text="Vazgeç"/>
</li>
</ul>
</div>
and this is my cotroller.ascx.cs
protected void Login_Authenticate(object sender, EventArgs e)
{
bool authenticated = AuthenticateMe(kullanıcı_adi.Text, sifre.Text, true);
if (authenticated)
{
FormsAuthentication.RedirectFromLoginPage(kullanıcı_adi.Text, true);
}
}
and this is the default.aspx
<li class="gallery"><a 开发者_JAVA技巧id="various1" href="#inline1">Üye ol/Giriş Yap</a></li>
<div style="display: none;">
<co:c_login ID="id_c_login" runat="server" EnableViewState=true />
</div>
I found the solution. Same question asked before. Fancybox - ASP.NET button not working Thank you for your answers.
A bit late, but it may help you.
This is because how fancybox works, when fancybox displays the div block, it creates temporary div block with your content and appends it to end of the body tag of the page, hence this generated temporary block is created outside form tag.
In a web page when you postback a page, the control which generates postback event must be within form tag to identify the page postback action.
To resolve this issue you can use a bit of javascript, create another button control but it should not be part of fancybox control, and on submit button within fancybox, fire click event of another created button (which will be inside form tag) with help of javascript.
That should solve your problem, please vote if it answer your question.
We can solve fancybox 2 event not firing issue by using parent property of fancybox. for example -
$("#buttonClick").fancybox({
parent: "form:first",//Asp.net Button click event not working issue solved by using this statement
......your fancybox config options
});
精彩评论