I am using thickbox (its kind of a lightbox type) for my login page. It has a built in script that allows you to close the thickbox just by placing the following on the onclick event of any link like so:
<a
href="#"
onclick="window.top.tb_remove();">
I tried placing this on the onloggedin event of the asp login like so:
I am using thickbox (its kind of a lightbox type) for my login page. It has a built in script that allows you to close the thickbox just by placing the following on the onclick event of any link like so:
<a
href="#"
onclick="window.top.tb_remove();">
I tried placing this on the onloggedin event of the asp login like so:
I tried your suggested code, it seems there is something preventing the javascript to be fired on server-side events.
I experimented and since it was a log-in page, I thought to have the DestinationUrl of the login control to a blank page and have a client side code fire there. I would like to share it to others that would encouter this:
jvpanganiban
Member
13 Points
10 Posts
calling javascript from onloggedin event of asp login
May 07, 2009 10:27 AM|LINK
Hi to all,
I am using thickbox (its kind of a lightbox type) for my login page. It has a built in script that allows you to close the thickbox just by placing the following on the onclick event of any link like so:
<a href="#" onclick="window.top.tb_remove();">I tried placing this on the onloggedin event of the asp login like so:
<
asp:Login ID="Login1" runat="server" onloggedin="window.top.tb_remove();">I am quite sure that the event is happening but the javascipt is not triggered.
Please help
Thanks
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: calling javascript from onloggedin event of asp login
May 07, 2009 02:55 PM|LINK
Because LoggedIn is a server-side method and not a client-side one.
aspx file:
<asp:Login id="Login1" runat="server" OnLoggedIn="OnLoggedIn"></asp:Login>
CodeBehind:
protected void OnLoggedIn(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "OnLoggedInScript", "window.top.tb_remove();", true);
}
NC...
jvpanganiban
Member
13 Points
10 Posts
Re: calling javascript from onloggedin event of asp login
May 07, 2009 06:25 PM|LINK
Thank you for your reply NC,
I tried your suggested code, it seems there is something preventing the javascript to be fired on server-side events.
I experimented and since it was a log-in page, I thought to have the DestinationUrl of the login control to a blank page and have a client side code fire there. I would like to share it to others that would encouter this:
On my login control:
<asp:Login id="Login1" runat="server" DestinationPageUrl="~/Redirect.aspx" asp:Login>
On my Redirect.aspx.cs, I followed your code:
protected void Page_Load(object sender, EventArgs e){
ClientScript.RegisterStartupScript(GetType(), "OnLoggedInScript", "window.top.tb_remove();", true);}
It worked lilke a charm. Thank you for taking the time NC...