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. HTTP 404

HTTP 404

Scheduled Pinned Locked Moved ASP.NET
databasecsharpcssasp-nethelp
18 Posts 4 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.
  • F Franco Cipriano

    Thanks!I will try those changes. I am not sure what Page.IsPostBack() but I will do a research on that. Thanks!

    Z Offline
    Z Offline
    ZurdoDev
    wrote on last edited by
    #4

    There are a lot of controls in .Net which cause postbacks. For example a button when clicked and even dropdowns, although you can control it. So, you normally only want to retrieve your data when the page loads for the first time, not when controls are causing a postback. So, in Page_Load check if (!IsPostBack()) then do your select.

    There are only 10 types of people in the world, those who understand binary and those who don't.

    F 1 Reply Last reply
    0
    • Z ZurdoDev

      There are a lot of controls in .Net which cause postbacks. For example a button when clicked and even dropdowns, although you can control it. So, you normally only want to retrieve your data when the page loads for the first time, not when controls are causing a postback. So, in Page_Load check if (!IsPostBack()) then do your select.

      There are only 10 types of people in the world, those who understand binary and those who don't.

      F Offline
      F Offline
      Franco Cipriano
      wrote on last edited by
      #5

      I tried your suggestions but, this time everytime I click the select button it still gives me the same error. Here is the code behind from the WebForm1.aspx

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using MySql.Data.MySqlClient;

      namespace AccoutMgt
      {
      public partial class WebForm1 : System.Web.UI.Page
      {

          protected void Page\_Load(object sender, EventArgs e)
          {
              if (Page.Request.QueryString\["name"\] != null)
              {
                  txtMPSname.Text = Page.Request.QueryString\["name"\];
                  txtLoc.Text = Page.Request.QueryString\["location"\];
                  DlstGeo.DataValueField = Page.Request.QueryString\["geo"\];
              }
          }
      
          protected void BtnSearch\_Click(object sender, EventArgs e)
          {
      
          }
      
      }
      

      }

      and here is the code from frmList.aspx

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using MySql.Data.MySqlClient;

      namespace AccoutMgt
      {
      public partial class List : System.Web.UI.Page
      {
      //public static string connStr = "SERVER=157.184.82.187;DATABASE=acctinformation;UID=root;PASSWORD=l3xmark;pooling=false;";
      //public static MySqlConnection mycon;
      //ClassProj cs1 = new ClassProj();

          protected void Page\_Load(object sender, EventArgs e)
          {
              if (ClassProj.GetDBconn() == true)
              {
                  if (!IsPostBack)
                  {
                      String SQLstr = "SELECT a.ID, a.NAME AS Name,b.NAME AS Industry,a.subindustry as SubIndustry,a.geo AS Geo,c.NAME AS LocType FROM mpsacct AS a,industry AS b,location AS c WHERE a.industry=b.id AND a.loctype=c.id";
                      MySqlCommand cmd = new MySqlCommand(SQLstr, ClassProj.mycon);
                      MySqlDataReader reader = cmd.ExecuteReader();
      
                      //Bind the grid view
                      grdAll.DataSource = reader;
                      grdAll.DataBind();
      
                      reader.Close();
                      cmd.Dispose();
                  }
              }
      
              ClassProj.CloseConn();
          }
      
          public void MPS\_Selected(Object sender, GridViewCommandEventArgs e)
          {
              if (e.CommandName == "Select")
              {
                  // C
      
      Z 1 Reply Last reply
      0
      • F Franco Cipriano

        I tried your suggestions but, this time everytime I click the select button it still gives me the same error. Here is the code behind from the WebForm1.aspx

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;
        using MySql.Data.MySqlClient;

        namespace AccoutMgt
        {
        public partial class WebForm1 : System.Web.UI.Page
        {

            protected void Page\_Load(object sender, EventArgs e)
            {
                if (Page.Request.QueryString\["name"\] != null)
                {
                    txtMPSname.Text = Page.Request.QueryString\["name"\];
                    txtLoc.Text = Page.Request.QueryString\["location"\];
                    DlstGeo.DataValueField = Page.Request.QueryString\["geo"\];
                }
            }
        
            protected void BtnSearch\_Click(object sender, EventArgs e)
            {
        
            }
        
        }
        

        }

        and here is the code from frmList.aspx

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;
        using MySql.Data.MySqlClient;

        namespace AccoutMgt
        {
        public partial class List : System.Web.UI.Page
        {
        //public static string connStr = "SERVER=157.184.82.187;DATABASE=acctinformation;UID=root;PASSWORD=l3xmark;pooling=false;";
        //public static MySqlConnection mycon;
        //ClassProj cs1 = new ClassProj();

            protected void Page\_Load(object sender, EventArgs e)
            {
                if (ClassProj.GetDBconn() == true)
                {
                    if (!IsPostBack)
                    {
                        String SQLstr = "SELECT a.ID, a.NAME AS Name,b.NAME AS Industry,a.subindustry as SubIndustry,a.geo AS Geo,c.NAME AS LocType FROM mpsacct AS a,industry AS b,location AS c WHERE a.industry=b.id AND a.loctype=c.id";
                        MySqlCommand cmd = new MySqlCommand(SQLstr, ClassProj.mycon);
                        MySqlDataReader reader = cmd.ExecuteReader();
        
                        //Bind the grid view
                        grdAll.DataSource = reader;
                        grdAll.DataBind();
        
                        reader.Close();
                        cmd.Dispose();
                    }
                }
        
                ClassProj.CloseConn();
            }
        
            public void MPS\_Selected(Object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
                    // C
        
        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #6

        Is WebForm1 in the root of the site? That is what the ~ does. It puts you to the root so make sure that Response.Redirect(path) is correct.

        There are only 10 types of people in the world, those who understand binary and those who don't.

        F 1 Reply Last reply
        0
        • Z ZurdoDev

          Is WebForm1 in the root of the site? That is what the ~ does. It puts you to the root so make sure that Response.Redirect(path) is correct.

          There are only 10 types of people in the world, those who understand binary and those who don't.

          F Offline
          F Offline
          Franco Cipriano
          wrote on last edited by
          #7

          They are located on the same path. The WebForm1.aspx is the start page and serves as the parent. The frmList.aspx is a pop-up window. Basically what should happen is the frmList.aspx will call back the WebForm1.aspx and pass the values to the controls of WebForm1.aspx. Thanks,

          Z 1 Reply Last reply
          0
          • F Franco Cipriano

            They are located on the same path. The WebForm1.aspx is the start page and serves as the parent. The frmList.aspx is a pop-up window. Basically what should happen is the frmList.aspx will call back the WebForm1.aspx and pass the values to the controls of WebForm1.aspx. Thanks,

            Z Offline
            Z Offline
            ZurdoDev
            wrote on last edited by
            #8

            I know, but is WebForm1 under a folder? Or is it at the root of your site?

            There are only 10 types of people in the world, those who understand binary and those who don't.

            F 1 Reply Last reply
            0
            • Z ZurdoDev

              I know, but is WebForm1 under a folder? Or is it at the root of your site?

              There are only 10 types of people in the world, those who understand binary and those who don't.

              F Offline
              F Offline
              Franco Cipriano
              wrote on last edited by
              #9

              It's in the root of the site. I'm not sure where the problem is, since when I run the debug it does not go anywhere when I click the button in the GridView. Here is the ASP code of the GridView at frmList.aspx

              <asp:GridView ID="grdAll" runat="server" OnRowCommand="MPS_Selected" AutoGenerateColumns="false">
              <Columns>
              <asp:BoundField DataField="ID" HeaderText = "" Visible="false" />
              <asp:BoundField DataField="Name" HeaderText = "MPS Account Name" />
              <asp:BoundField DataField="Industry" HeaderText = "Industry" />
              <asp:BoundField DataField="SubIndustry" HeaderText = "Sub-Industry" />
              <asp:BoundField DataField="Geo" HeaderText = "Geo" />
              <asp:BoundField DataField="LocType" HeaderText = "Location" />
              <asp:buttonfield buttontype="Button" commandname="Select" headertext="" text="Select"/>
              </Columns>

                  </asp:GridView>
              
              Z 1 Reply Last reply
              0
              • F Franco Cipriano

                It's in the root of the site. I'm not sure where the problem is, since when I run the debug it does not go anywhere when I click the button in the GridView. Here is the ASP code of the GridView at frmList.aspx

                <asp:GridView ID="grdAll" runat="server" OnRowCommand="MPS_Selected" AutoGenerateColumns="false">
                <Columns>
                <asp:BoundField DataField="ID" HeaderText = "" Visible="false" />
                <asp:BoundField DataField="Name" HeaderText = "MPS Account Name" />
                <asp:BoundField DataField="Industry" HeaderText = "Industry" />
                <asp:BoundField DataField="SubIndustry" HeaderText = "Sub-Industry" />
                <asp:BoundField DataField="Geo" HeaderText = "Geo" />
                <asp:BoundField DataField="LocType" HeaderText = "Location" />
                <asp:buttonfield buttontype="Button" commandname="Select" headertext="" text="Select"/>
                </Columns>

                    </asp:GridView>
                
                Z Offline
                Z Offline
                ZurdoDev
                wrote on last edited by
                #10

                404 means it cannot find the file. So, put a breakpoint and see what url it is trying to go to. Also, if the url is correct try adding the Everyone group to the folder with full control because you may have an issue where file level security is preventing IIS from seeing the file.

                There are only 10 types of people in the world, those who understand binary and those who don't.

                F 1 Reply Last reply
                0
                • Z ZurdoDev

                  404 means it cannot find the file. So, put a breakpoint and see what url it is trying to go to. Also, if the url is correct try adding the Everyone group to the folder with full control because you may have an issue where file level security is preventing IIS from seeing the file.

                  There are only 10 types of people in the world, those who understand binary and those who don't.

                  F Offline
                  F Offline
                  Franco Cipriano
                  wrote on last edited by
                  #11

                  Hi, Where do I do that in the file? Sorry for the questions, I am very new to this. I just started a week ago. And I am stuck on finding a way of passing back a value from a page to it's parent page. Thanks,

                  Z 1 Reply Last reply
                  0
                  • F Franco Cipriano

                    Hi, Where do I do that in the file? Sorry for the questions, I am very new to this. I just started a week ago. And I am stuck on finding a way of passing back a value from a page to it's parent page. Thanks,

                    Z Offline
                    Z Offline
                    ZurdoDev
                    wrote on last edited by
                    #12

                    Can you post a screen shot of the file structure maybe?

                    There are only 10 types of people in the world, those who understand binary and those who don't.

                    F 1 Reply Last reply
                    0
                    • F Franco Cipriano

                      Hi, I am new in ASP.NET c# web application development. I am creating a simple Account Management application. I am experiencing an error when using QueryString to pass value to a form. I have a main form named WebForm1.aspx. When I click a button named View List, it will pop-up a separate window with a gridview displaying all the account from a SQL database. The new window is called frmList.aspx, the gridview has a button on each row, and when I click the button it should transfer the data from the row to several textbox in the first page, WebForm1.aspx. But after I click the button it gives me an error. Below is the code behind for frmList.aspx

                      protected void Page_Load(object sender, EventArgs e)
                      {
                      if (ClassProj.GetDBconn() == true)
                      {
                      String SQLstr = "SELECT a.ID, a.NAME AS Name,b.NAME AS Industry,a.subindustry as SubIndustry,a.geo AS Geo,c.NAME AS LocType FROM mpsacct AS a,industry AS b,location AS c WHERE a.industry=b.id AND a.loctype=c.id";
                      MySqlCommand cmd = new MySqlCommand(SQLstr, ClassProj.mycon);
                      MySqlDataReader reader = cmd.ExecuteReader();

                                  //Bind the grid view
                                  grdAll.DataSource = reader;
                                  grdAll.DataBind();
                      
                                  reader.Close();
                                  cmd.Dispose();
                              }
                      
                              ClassProj.CloseConn();
                          }
                      
                          public void MPS\_Selected(Object sender, GridViewCommandEventArgs e)
                          {
                              if (e.CommandName == "Select")
                              {
                                  // Convert the row index stored in the CommandArgument
                                  // property to an Integer.
                                  int index = Convert.ToInt32(e.CommandArgument);
                                  //Populate textbox with selected values
                      
                                  //String s = Request.QueryString\["grdAll.Rows\[index\].Cells\[1\].Text.ToString();"\];
                                  string name = grdAll.Rows\[index\].Cells\[1\].Text.ToString();
                                  string Industry = grdAll.Rows\[index\].Cells\[2\].Text.ToString();
                                  string SubInd = grdAll.Rows\[index\].Cells\[3\].Text.ToString();
                                  string geo = grdAll.Rows\[index\].Cells\[4\].Text.ToString();
                                  string location = grdAll.Rows\[index\].Cells\[5\].Text.ToString();
                      
                                  Page.Response.Redirect("WebForm1.aspx?name=" + name + "&industry=" + Industry + "&subind=" + SubInd + "&geo=" + geo + "&location=" + location);
                              }
                          }
                      
                      F Offline
                      F Offline
                      frostcox
                      wrote on last edited by
                      #13

                      Hey, have you debugged through your code and seen where it exactly crashes? place breakpoints in each function and see what exactly is the problem. Like the app could be failing because the url is incorrect, or it might be trying to parse out a value that is not there from your querystring. Anyway find out exactly where its crashing and il gladly help you.

                      F 1 Reply Last reply
                      0
                      • F Franco Cipriano

                        Hi, I am new in ASP.NET c# web application development. I am creating a simple Account Management application. I am experiencing an error when using QueryString to pass value to a form. I have a main form named WebForm1.aspx. When I click a button named View List, it will pop-up a separate window with a gridview displaying all the account from a SQL database. The new window is called frmList.aspx, the gridview has a button on each row, and when I click the button it should transfer the data from the row to several textbox in the first page, WebForm1.aspx. But after I click the button it gives me an error. Below is the code behind for frmList.aspx

                        protected void Page_Load(object sender, EventArgs e)
                        {
                        if (ClassProj.GetDBconn() == true)
                        {
                        String SQLstr = "SELECT a.ID, a.NAME AS Name,b.NAME AS Industry,a.subindustry as SubIndustry,a.geo AS Geo,c.NAME AS LocType FROM mpsacct AS a,industry AS b,location AS c WHERE a.industry=b.id AND a.loctype=c.id";
                        MySqlCommand cmd = new MySqlCommand(SQLstr, ClassProj.mycon);
                        MySqlDataReader reader = cmd.ExecuteReader();

                                    //Bind the grid view
                                    grdAll.DataSource = reader;
                                    grdAll.DataBind();
                        
                                    reader.Close();
                                    cmd.Dispose();
                                }
                        
                                ClassProj.CloseConn();
                            }
                        
                            public void MPS\_Selected(Object sender, GridViewCommandEventArgs e)
                            {
                                if (e.CommandName == "Select")
                                {
                                    // Convert the row index stored in the CommandArgument
                                    // property to an Integer.
                                    int index = Convert.ToInt32(e.CommandArgument);
                                    //Populate textbox with selected values
                        
                                    //String s = Request.QueryString\["grdAll.Rows\[index\].Cells\[1\].Text.ToString();"\];
                                    string name = grdAll.Rows\[index\].Cells\[1\].Text.ToString();
                                    string Industry = grdAll.Rows\[index\].Cells\[2\].Text.ToString();
                                    string SubInd = grdAll.Rows\[index\].Cells\[3\].Text.ToString();
                                    string geo = grdAll.Rows\[index\].Cells\[4\].Text.ToString();
                                    string location = grdAll.Rows\[index\].Cells\[5\].Text.ToString();
                        
                                    Page.Response.Redirect("WebForm1.aspx?name=" + name + "&industry=" + Industry + "&subind=" + SubInd + "&geo=" + geo + "&location=" + location);
                                }
                            }
                        
                        W Offline
                        W Offline
                        wikizhao
                        wrote on last edited by
                        #14

                        may be you can use ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('msg!')"); show you info.the Response when you jump another page,that can use. did you ?

                        F 1 Reply Last reply
                        0
                        • Z ZurdoDev

                          Can you post a screen shot of the file structure maybe?

                          There are only 10 types of people in the world, those who understand binary and those who don't.

                          F Offline
                          F Offline
                          Franco Cipriano
                          wrote on last edited by
                          #15

                          This is the method that I use to show a new window, I'm not sure what is wrong but it won't work anymore

                          protected void btnAll_Click(object sender, EventArgs e)
                          {

                                 System.Text.StringBuilder sb = new System.Text.StringBuilder();
                                 sb.Append("<script language='javascript'>");
                                 sb.Append("window.open('frmList.aspx', 'MPS Account List',");
                                 sb.Append("'top=0, left=0, width='500', height='700', menubar=no,toolbar=yes,status,resizable=yes,addressbar=yes');<");
                                 sb.Append("/script>");
                          
                                 Type t = this.GetType();
                          
                                 if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
                                     ClientScript.RegisterClientScriptBlock(t, "PopupScript", sb.ToString());
                          
                             }
                          
                          1 Reply Last reply
                          0
                          • F frostcox

                            Hey, have you debugged through your code and seen where it exactly crashes? place breakpoints in each function and see what exactly is the problem. Like the app could be failing because the url is incorrect, or it might be trying to parse out a value that is not there from your querystring. Anyway find out exactly where its crashing and il gladly help you.

                            F Offline
                            F Offline
                            Franco Cipriano
                            wrote on last edited by
                            #16

                            Yes, I placed some breakpoints, but when I click on the button where it will pop-up a window it won't stop on the breakpoint..here is the code for the pop-up window and the code for the passing back the value from the gridview to the parent page. //code for pop-up window

                            protected void btnAll_Click(object sender, EventArgs e)
                            {

                                   System.Text.StringBuilder sb = new System.Text.StringBuilder();
                                   sb.Append("<script language='javascript'>");
                                   sb.Append("window.open('frmList.aspx', 'MPS Account List',");
                                   sb.Append("'top=0, left=0, width='500', height='700', menubar=no,toolbar=yes,status,resizable=yes,addressbar=yes');<");
                                   sb.Append("/script>");
                            
                                   Type t = this.GetType();
                            
                                   if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
                                       ClientScript.RegisterClientScriptBlock(t, "PopupScript", sb.ToString());
                            
                               }
                            

                            //code for passing value back

                            public void MPS_Selected(Object sender, GridViewCommandEventArgs e)
                            {
                            if (e.CommandName == "Select")
                            {

                                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script type='text/javascript'>alert('msg!')</script>");
                            
                                        // Convert the row index stored in the CommandArgument
                                        // property to an Integer.
                                        int index = Convert.ToInt32(e.CommandArgument);
                                        //Populate textbox with selected values
                            
                                        //String s = Request.QueryString\["grdAll.Rows\[index\].Cells\[1\].Text.ToString();"\];
                                        string name = grdAll.Rows\[index\].Cells\[1\].Text.ToString();
                                        string Industry = grdAll.Rows\[index\].Cells\[2\].Text.ToString();
                                        string SubInd = grdAll.Rows\[index\].Cells\[3\].Text.ToString();
                                        string geo = grdAll.Rows\[index\].Cells\[4\].Text.ToString();
                                        string location = grdAll.Rows\[index\].Cells\[5\].Text.ToString();
                            
                                        Page.Response.Redirect("~/WebForm1.aspx?name=" + name + "&industry=" + Industry + "&subind=" + SubInd + "&geo=" + geo + "&location=" + location);
                            
                            
                                        //HttpContext \_context = HttpContext.Current;
                                        //\_context.Items.Add("name", na
                            
                            1 Reply Last reply
                            0
                            • W wikizhao

                              may be you can use ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('msg!')"); show you info.the Response when you jump another page,that can use. did you ?

                              F Offline
                              F Offline
                              Franco Cipriano
                              wrote on last edited by
                              #17

                              what should I put on the 'msg!'? when the place this code on the method it only pop's up msg on the messagebox. Thanks!

                              W 1 Reply Last reply
                              0
                              • F Franco Cipriano

                                what should I put on the 'msg!'? when the place this code on the method it only pop's up msg on the messagebox. Thanks!

                                W Offline
                                W Offline
                                wikizhao
                                wrote on last edited by
                                #18

                                'msg!' mean info you want to put on this pleace! string try{}catch{} this things that all you can put on it!It loooks like UI page javascript alert(""); Hope can help you

                                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