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. alert dont display

alert dont display

Scheduled Pinned Locked Moved ASP.NET
helpquestion
3 Posts 3 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.
  • B Offline
    B Offline
    behzadcp
    wrote on last edited by
    #1

    hi guys i have a website that in button execute some methods and with this code response.write("alert(\"messge\") "); and then response.redirect("a.aspx"); now alert do not display whats problem ? thanks a lot

    S M 2 Replies Last reply
    0
    • B behzadcp

      hi guys i have a website that in button execute some methods and with this code response.write("alert(\"messge\") "); and then response.redirect("a.aspx"); now alert do not display whats problem ? thanks a lot

      S Offline
      S Offline
      Sebastien T
      wrote on last edited by
      #2

      If I understand, when a user click on the button. In the event you have:

      void btnTest_Click(object sender, EventArgs e)
      {
      Response.Write("<Script>alert('messge') </Script>");
      Response.Redirect("page2");
      }

      in this case, the redirection is make and the page with the button cannot display the alert. For resolve you problem try:

      <script language="javascript">
      function onButtonClick()
      {
      alert("message");
      document.location = "http://www.google.fr";
      }
      </script>

      <asp:Button ID="btnTest" runat="server" OnClientClick="javascript:onButtonClick()" />

      If you have some thing to execute in the event, you can make this

          void btnTest\_Click(object sender, EventArgs e)
          {
              Response.Write(@"<Script> alert('message');
                               document.location = 'http://www.google.fr'; </Script>");
          }
      

      modified on Tuesday, November 30, 2010 8:04 AM

      1 Reply Last reply
      0
      • B behzadcp

        hi guys i have a website that in button execute some methods and with this code response.write("alert(\"messge\") "); and then response.redirect("a.aspx"); now alert do not display whats problem ? thanks a lot

        M Offline
        M Offline
        Manfred Rudolf Bihy
        wrote on last edited by
        #3

        If you're doing a Response.Redirect("someUrl"). The redirect will be done on the server side. That means you're transfering control to the execution of page a.aspx. The former writing of that script tag is hereby irrelevant. Cheers Manfred

        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