Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I am submitting the data on Page and getting the error.
I have below page <a href="http://localhost:53897/SubmitAdd.aspx"> and on it have Submit button. When I am pressing Submit button new same page open and give error.
C#
This site can’t be reached

The connection was reset.
Try:
Reloading the page
Checking the connection

C#
Checking the proxy and the firewall
ERR_CONNECTION_RESET


What I have tried:

C#
protected void Page_Load(object sender, EventArgs e)
{
    //if (IsPostBack)
    //{
    //    int a=0;
    //}

    //if (Session["UserIsLogged"] == null)
    //{
    //    Response.Redirect("Login.aspx");
    //}


    //if (!IsPostBack)
    //{
    //    BindStates();
    //}
}

protected void btnSubmitAd_Click(object sender, EventArgs e)
{
     string imageName = fileUploadImage.FileName;
   

    if(!(imageName.EndsWith(".png") || imageName.EndsWith(".jpg") || imageName.EndsWith(".jpeg")))
    {
        lblerrorMesssage.Text = "Image should be of type .jpeg,.jpg,.png only";
        return;
    }

    string im="AdImages/" + imageName;
   
    SubmitAdDetail SubmitAdObject = new SubmitAdDetail();

    if (System.IO.File.Exists(Server.MapPath("AdImages/" + imageName)))
    {
        string newImageName = DateTime.Now.ToString("yyMMddHHmmss") + imageName;
        fileUploadImage.SaveAs(Server.MapPath("AdImages/" + newImageName));
        SubmitAdObject.imageName = newImageName;
    }
    else
    {
        fileUploadImage.SaveAs(Server.MapPath("AdImages/" + imageName));
        SubmitAdObject.imageName = imageName;
    }

    SubmitAdObject.adTitle = txtBoxTitle.Text;
    SubmitAdObject.type = Convert.ToInt32(rblType.SelectedValue.ToString());
    SubmitAdObject.furnishingType = Convert.ToInt32(rblFurnishing.SelectedValue.ToString());
    SubmitAdObject.dealType = Convert.ToInt32(rblDeal.SelectedValue.ToString());
    SubmitAdObject.price = Convert.ToInt32(txtBoxPrice.Text.ToString());
    SubmitAdObject.address = txtBoxAddress.Text;
    SubmitAdObject.city = Convert.ToInt32(ddlCity.SelectedValue.ToString());
    
    SubmitAdObject.mobile = txtMobile.Text;
    SubmitAdObject.name = txtBoxName.Text;
    SubmitAdObject.rooms = Convert.ToInt32(rblRooms.SelectedValue.ToString());
    SubmitAdObject.state = Convert.ToInt32(ddlState.SelectedValue.ToString());
    SubmitAdObject.stateName = ddlState.SelectedItem.Text.ToString();
    SubmitAdObject.cityName = ddlCity.SelectedItem.ToString();

    if (SubmitAdDAL.SubmitAd(SubmitAdObject))
    {

    }
    else
    {

    }
   
}

public void BindStates()
{
    SqlConnection conn = CreateConnection.MakeConnectionToAHStateManagement();

    SqlCommand cmd = new SqlCommand();
    cmd.Connection = conn;
    cmd.CommandText = "GetStates";
    cmd.CommandType = CommandType.StoredProcedure;
    SqlDataAdapter stateAdapter = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    stateAdapter.Fill(ds);

    ddlState.DataSource = ds;
    ddlState.DataTextField="StateName";
    ddlState.DataValueField = "StateID";
    ddlState.DataBind();

    ddlState.Items.Insert(0, new ListItem("Select State", "0"));
    ddlState.SelectedIndex = 0;


}
Posted
Updated 9-Jun-16 0:59am
v2
Comments
Kornfeld Eliyahu Peter 8-Jun-16 16:49pm    
How you came by that port number? Maybe you wrote some fixed, but it is dynamic?

1 solution

remove href from <a> tag and replace with it

ASP.NET
<a id="btnSubmitAd" onserverclick="btnSubmitAd_Click"
         runat="server" >  
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900