onclick for button and window.location.href

C

Chuck

I want to open the FormsAuthentication Logon Page using javascript, not a
Response.Redirect.

I can't get it to work. If I have the onclick Javascript read window.open,
it works fine. If I use window.location or window.location.href it does not.


<asp:Button ID="btnLogOut" runat="server" Text="Log Out" />
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False">LinkButton</asp:LinkButton>




btnLogOut.Attributes.Add("onclick","window.location.href('"+
FormsAuthentication.LoginUrl + "?logout=true'); return false;");

LinkButton1.PostBackUrl=(FormsAuthentication.LoginUrl + "?logout=true");

The linkButton does work the regular button does not.



<input type="submit" id="ctl00_ContentMain_btnLogOut"
onclick="window.location.href('http://localhost/HRAuth/LogIn.aspx?logout=true'); return false;" value="Log Out" name="ctl00$ContentMain$btnLogOut">

<a href="javascript:WebForm_DoPostBackWithOptions(new
WebForm_PostBackOptions("ctl00$ContentMain$LinkButton1", "", false, "",
"http://localhost/HRAuth/LogIn.aspx?logout=true", false, true))"
id="ctl00_ContentMain_LinkButton1">LinkButton</a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top