Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Linkbutton, Target="_blank"

Linkbutton, Target="_blank"

Scheduled Pinned Locked Moved C#
tutorial
15 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J JohnQuar1

    Hey, I have a couple of link buttons and I am trying to get them to open a page in a new window. I know how to do this with a normal link, but I also have some very simple code behind that I need to run (Set a session variable). I've tried to add attributes to the linkbutton by doing lnkBtnEnterprise.Attributes.Add("Target", "_blank"); but that doesnt seem to do anything. Let me know if you have any suggestions. Thanks for your time.

    protected void lnkBtnEnterprise_Click(object sender, EventArgs e)
    {
    lnkBtnEnterprise.Attributes.Add("Target", "_blank");
    Session["Owner"] = 1;
    Response.Redirect("~/SampleDashboardDetails.aspx");
    }

    JM

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    I have absolutely no clue, is this ASP.NET?

    J N 2 Replies Last reply
    0
    • L Lost User

      I have absolutely no clue, is this ASP.NET?

      J Offline
      J Offline
      JohnQuar1
      wrote on last edited by
      #5

      Yes, it is ASP.NET. I was trying to open the page using C# and w/o javascript. I've spent all day trying to figure it out to no avail. When I do the lnkBtnEnterprise.Attributes.Add("target", "_blank"); and click the button on the page, I get an error of "Microsoft JScript runtime error: Object expected"

      C 1 Reply Last reply
      0
      • J JohnQuar1

        Yes, it is ASP.NET. I was trying to open the page using C# and w/o javascript. I've spent all day trying to figure it out to no avail. When I do the lnkBtnEnterprise.Attributes.Add("target", "_blank"); and click the button on the page, I get an error of "Microsoft JScript runtime error: Object expected"

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #6

        WE have an ASP.NET forum. Posting in the C# forum leaves people trying to figure out if you're writing a web app, which is often less obvious than it was in this case.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        J 1 Reply Last reply
        0
        • C Christian Graus

          WE have an ASP.NET forum. Posting in the C# forum leaves people trying to figure out if you're writing a web app, which is often less obvious than it was in this case.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          J Offline
          J Offline
          JohnQuar1
          wrote on last edited by
          #7

          OK, but its a C#.Net question, is it not? Thats why I thought this forum was more appropriate.

          H 1 Reply Last reply
          0
          • J JohnQuar1

            OK, but its a C#.Net question, is it not? Thats why I thought this forum was more appropriate.

            H Offline
            H Offline
            Henry Minute
            wrote on last edited by
            #8

            The code might be in C# but the concepts are either Web Development or ASP.Net, either of which would, in my opinion, be better homes for your question.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            J 1 Reply Last reply
            0
            • H Henry Minute

              The code might be in C# but the concepts are either Web Development or ASP.Net, either of which would, in my opinion, be better homes for your question.

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              J Offline
              J Offline
              JohnQuar1
              wrote on last edited by
              #9

              OK, I'll post the question over there. Thanks anyway for your help.

              J 1 Reply Last reply
              0
              • L Lost User

                I have absolutely no clue, is this ASP.NET?

                N Offline
                N Offline
                Not Active
                wrote on last edited by
                #10

                :omg: :wtf: Seriously, WTF. Session, Response??? This doesn't give you a clue??


                only two letters away from being an asset

                L 2 Replies Last reply
                0
                • N Not Active

                  :omg: :wtf: Seriously, WTF. Session, Response??? This doesn't give you a clue??


                  only two letters away from being an asset

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #11

                  Barely, sounds like webcrap, I'm not into that at all

                  1 Reply Last reply
                  0
                  • N Not Active

                    :omg: :wtf: Seriously, WTF. Session, Response??? This doesn't give you a clue??


                    only two letters away from being an asset

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #12

                    btw did you onevote me for not having a clue?

                    J 1 Reply Last reply
                    0
                    • J JohnQuar1

                      OK, I'll post the question over there. Thanks anyway for your help.

                      J Offline
                      J Offline
                      JohnQuar1
                      wrote on last edited by
                      #13

                      I found a solution. I ended up changing the link buttons to links and passed a variable through the link, then grabbed the variable and stored it to the session variable I was using in a Page_PreInit function. Send it from first page: Receive on second page:

                      protected void Page_PreInit(Object sender, EventArgs e)
                      {
                      Session["Owner"] = Request.QueryString["Owner"];
                      }

                      Thanks for your help guys.

                      U 1 Reply Last reply
                      0
                      • L Lost User

                        btw did you onevote me for not having a clue?

                        J Offline
                        J Offline
                        JohnQuar1
                        wrote on last edited by
                        #14

                        No, I did not. I'm not even sure what onevote is.

                        1 Reply Last reply
                        0
                        • J JohnQuar1

                          I found a solution. I ended up changing the link buttons to links and passed a variable through the link, then grabbed the variable and stored it to the session variable I was using in a Page_PreInit function. Send it from first page: Receive on second page:

                          protected void Page_PreInit(Object sender, EventArgs e)
                          {
                          Session["Owner"] = Request.QueryString["Owner"];
                          }

                          Thanks for your help guys.

                          U Offline
                          U Offline
                          User 3642123
                          wrote on last edited by
                          #15

                          <asp:LinkButton ID="lbtnValidRules" runat="server" Text="Validation Rules" OnClientClick="window.open('ValidationRules.aspx', 'ValidRules', 'width=1100,height=800,status=yes'); return false;">
                          </asp:LinkButton>

                          this is how I do

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups