locked
Access Counter Not Counting on Image Click in IE? RRS feed

  • Question

  • User110112739 posted

    When you click the following in 'Chrome' it goes to the URL and adds 1 to the counter, yet when you do the same in 'IE' it goes to the URL but doesn't add one to the counter?????

    File Code = 

    <asp:ImageButton ID="ImageButton3" runat="server" Width="300" Height="213" onclick="ImageButton3_Click" imageurl="../images/actiw_banner.gif" PostBackUrl="http://www.actiw.com" OnClientClick="aspnetForm.target='_blank'"/>


    Code behind =

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        {
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\logistics.mdb;";
            string sql = "update CounterTable set actiwFIELD=actiwFIELD+1";
            System.Data.OleDb.OleDbCommand sdc = new System.Data.OleDb.OleDbCommand(sql, conn);
            sdc.CommandType = CommandType.Text;
            conn.Open();
            sdc.ExecuteNonQuery();
            conn.Close();
        }

         protected void ImageButton3_Click(object sender, ImageClickEventArgs e)

        {
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\logistics.mdb;";
            string sql = "update CounterTable set actiwFIELD=actiwFIELD+1";
            System.Data.OleDb.OleDbCommand sdc = new System.Data.OleDb.OleDbCommand(sql, conn);
            sdc.CommandType = CommandType.Text;

            conn.Open();
            sdc.ExecuteNonQuery();
            conn.Close();
        }

    Any thoughts anyone???


    Bish


    Thursday, December 9, 2010 3:21 PM

Answers

  • User110112739 posted

    Thats it!!!  

    Response.Redirect("http://www.actiw.com");


    Spot on.


    Many thanks for your help :-)


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 10, 2010 12:27 PM

All replies

  • User-957431521 posted

    hello

    i'm not sure but i think  ImageButton3_Click won't get called if you use PostBackUrl attribute with your button. try to use this :

    .aspx file =

    <asp:ImageButton ID="ImageButton3" runat="server" Width="300" Height="213" onclick="ImageButton3_Click" imageurl="../images/actiw_banner.gif" OnClientClick="aspnetForm.target='_blank'"/>

    in code behind :

    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)

        {
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\logistics.mdb;";
            string sql = "update CounterTable set actiwFIELD=actiwFIELD+1";
            System.Data.OleDb.OleDbCommand sdc = new System.Data.OleDb.OleDbCommand(sql, conn);
            sdc.CommandType = CommandType.Text;

            conn.Open();
            sdc.ExecuteNonQuery();
            conn.Close();
           
            Response.RedirectLocation = "http://www.actiw.com";
        }
     
     
    so we just moved the postback url location to code behind but we still using '_blank '.
     
    Thursday, December 9, 2010 5:10 PM
  • User110112739 posted

    OK tried this but it has now had the reverse effect, the database now counts but the page clicks through to 'Default.aspx' ??????

    Friday, December 10, 2010 11:35 AM
  • User-957431521 posted

    sorry my bad. use Response.Redirect(www.actiw.com); instead of Response.RedirectLocation.

    Friday, December 10, 2010 12:11 PM
  • User110112739 posted

    Thats it!!!  

    Response.Redirect("http://www.actiw.com");


    Spot on.


    Many thanks for your help :-)


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 10, 2010 12:27 PM