onclick for button and window.location.href

Discussion in 'ASP .Net Web Controls' started by Chuck, Feb 2, 2010.

  1. Chuck

    Chuck Guest

    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>
    Chuck, Feb 2, 2010
    #1
    1. Advertising

  2. Chuck

    Chuck Guest

    Never mind

    bad js syntax

    window.location = not window.location()

    "Chuck" wrote:

    > 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>
    Chuck, Feb 2, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joshua Beall
    Replies:
    26
    Views:
    219,883
    AndreiKaa
    Jun 29, 2007
  2. AAaron123
    Replies:
    3
    Views:
    7,662
    AAaron123
    May 1, 2009
  3. saiho.yuen
    Replies:
    3
    Views:
    402
    kaeli
    Sep 14, 2004
  4. Replies:
    2
    Views:
    440
  5. Vincent van Beveren

    BASE HREF and A HREF="#" onclick="..."

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    290
    Vincent van Beveren
    Jul 6, 2006
Loading...

Share This Page