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. Web Development
  3. ASP.NET
  4. Opening new window from C# code

Opening new window from C# code

Scheduled Pinned Locked Moved ASP.NET
csharpcomhelpquestion
4 Posts 2 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.
  • K Offline
    K Offline
    kaliem
    wrote on last edited by
    #1

    Hi All, I tried to open a new IE window from C# code and it works for any sample website. However, the same code doesnt work for ajax enabled website. I have removed ajax by deleting <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> from .aspx but still it doesnt work, any clues ??? Do i need to remove something more than that ? Here is my code for opening the new window that works on pages other than my website page: string strQS = "http://www.yahoo.com"; StringBuilder strScript = new StringBuilder(); strScript.Append(""); strScript.Append("window.open('" + strQS + "', \"\",\"height=100,width=400,left=0,top=0,toolbar=no,menubar=no\");"); strScript.Append(""); ClientScript.RegisterClientScriptBlock(this.GetType(), "subscribescript", strScript.ToString()); I would appreciate your help. Thanks Knowledge is knowing a tomato is a fruit. Wisdom is not putting it in a fruit salad.

    N 1 Reply Last reply
    0
    • K kaliem

      Hi All, I tried to open a new IE window from C# code and it works for any sample website. However, the same code doesnt work for ajax enabled website. I have removed ajax by deleting <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> from .aspx but still it doesnt work, any clues ??? Do i need to remove something more than that ? Here is my code for opening the new window that works on pages other than my website page: string strQS = "http://www.yahoo.com"; StringBuilder strScript = new StringBuilder(); strScript.Append(""); strScript.Append("window.open('" + strQS + "', \"\",\"height=100,width=400,left=0,top=0,toolbar=no,menubar=no\");"); strScript.Append(""); ClientScript.RegisterClientScriptBlock(this.GetType(), "subscribescript", strScript.ToString()); I would appreciate your help. Thanks Knowledge is knowing a tomato is a fruit. Wisdom is not putting it in a fruit salad.

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

      First, you can't open a new windOw using C#. you are using C# to inject Javascript that Will open a new window. where are you calling this code? Are you trying to hare this script called when the page is rendered on the client?


      only two letters away from being an asset

      K 1 Reply Last reply
      0
      • N Not Active

        First, you can't open a new windOw using C#. you are using C# to inject Javascript that Will open a new window. where are you calling this code? Are you trying to hare this script called when the page is rendered on the client?


        only two letters away from being an asset

        K Offline
        K Offline
        kaliem
        wrote on last edited by
        #3

        This code is called on my grid view event , I want to open a new window on grid event. But on this page where this code is not working, it is not working for any control , be it simple button click , and on other pages, it is working on same events, I wonder whats so special in this page , I thought it must be ajax creating problem but now i have removed its reference from the page with same result happening.

        N 1 Reply Last reply
        0
        • K kaliem

          This code is called on my grid view event , I want to open a new window on grid event. But on this page where this code is not working, it is not working for any control , be it simple button click , and on other pages, it is working on same events, I wonder whats so special in this page , I thought it must be ajax creating problem but now i have removed its reference from the page with same result happening.

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

          using a script library would be a better approach. are you sure the grid event is being called? check the function name. Is it a typo?


          only two letters away from being an asset

          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