Submit button is not working in code behind in my aspx.cs file
html
<div class="col-5">
<div class="row" style="background-color:pink; font-size:20px; text-align:center; font-weight:bold;">
<div class="col-12">User(s) Valuable Feedback/Suggestion Form :
<i class="fa fa-comments" style="font-size:24px; color:Blue;"></i>
</div>
</div>
<div class="row">
<div class="col-4">User Full Name :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:TextBox ID="txtUname" runat="server" CssClass="textbox_Feedback" Placeholder="User Full Name" required></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-4">User Mobile No. :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:TextBox ID="txtMobile" runat="server" CssClass="textbox_Feedback" Placeholder="User Mobile No." MaxLength="10" required></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-4">User Email :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:TextBox ID="txtEmail" runat="server" CssClass="textbox_Feedback" Placeholder="User Email" required></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-4">Comment Type :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:DropDownList ID="ddlCommentType" runat="server" CssClass="DropDownList" required>
<asp:ListItem Selected="True" Value="0">-Select-</asp:ListItem>
<asp:ListItem Value="01">Feedback</asp:ListItem>
<asp:ListItem Value="02">Suggestion</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="row">
<div class="col-4">Rate Us By Star :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:DropDownList ID="ddlStar" runat="server" CssClass="DropDownList" required>
<asp:ListItem Selected="True" Value="0">-Select-</asp:ListItem>
<asp:ListItem Value="01">*</asp:ListItem>
<asp:ListItem Value="02">**</asp:ListItem>
<asp:ListItem Value="03">***</asp:ListItem>
<asp:ListItem Value="04">****</asp:ListItem>
<asp:ListItem Value="05">*****</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="row">
<div class="col-4">Subject :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:TextBox ID="txtSub" runat="server" CssClass="textbox_Feedback" Placeholder="User Email" required></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-4">Write Something :<font style="color:Red;">*</font></div>
<div class="col-7">
<asp:TextBox ID="txtComment" runat="server" CssClass="textbox_Feedback" Placeholder="Your Valuable Feedback/Suggestions." TextMode="MultiLine" Height="80px" required></asp:TextBox>
</div>
</div>
<div class="row">
<div class="col-4">Attach a File :</div>
<div class="col-7">
<asp:FileUpload ID="FileUpload1" runat="server" />
ext. - jpeg/jpg/png/pdf only.
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-7">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="ButtonSave" OnClick="btnSubmit_Click" />
</div>
</div>
</div>
Code
protected void btnSubmit_Click(object sender, System.EventArgs e)
{
//..........................Client Ip Address...........................................................
string ipAddress = "";
ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipAddress == "" || ipAddress == null)
ipAddress = Request.ServerVariables["REMOTE_ADDR"];
//saving file in the physical folder;
string virtualFolder = "~/Uploads/Feed_Sugg/";
//Set file extension for Photo and sign
string file_ext = Path.GetExtension(FileUpload1.PostedFile.FileName).ToLower();
if (FileUpload1.HasFile)
{
if (file_ext == ".JPEG" || file_ext == ".jpg" || file_ext == ".png" || file_ext == ".bmp" || file_ext == ".pdf")
{
FileUpload1.SaveAs(Server.MapPath(virtualFolder) + "\\" + txtMobile.Text + "" + file_ext);
string photo = txtMobile.Text + "" + file_ext;
string physicalFolder = Server.MapPath(virtualFolder);
//img_Photo.Visible = true;
//img_Photo.ImageUrl = Server.MapPath(virtualFolder) + @"\" + lblCid.Text + "" + file_ext;
//Save Commands Method.............................................................................
cnn.Open();
SqlCommand cmd = new SqlCommand("insert_Community_FeedSuggs", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserId", SqlDbType.VarChar).Value = "";
cmd.Parameters.AddWithValue("@UserIp", ipAddress);
cmd.Parameters.AddWithValue("@CommType", ddlCommentType.SelectedItem.ToString());
cmd.Parameters.AddWithValue("@iNetChannel", SqlDbType.VarChar).Value = "";
cmd.Parameters.AddWithValue("@UserMobile", txtMobile.Text);
cmd.Parameters.AddWithValue("@UserEmail", txtEmail);
cmd.Parameters.AddWithValue("@TicketSubject", txtSub.Text);
cmd.Parameters.AddWithValue("@RatingByUser", ddlStar.SelectedItem.ToString());
cmd.Parameters.AddWithValue("@Comment", txtComment.Text);
cmd.Parameters.AddWithValue("@ImgPath", SqlDbType.VarChar).Value = "";
cmd.Parameters.AddWithValue("@ImgName", photo);
cmd.ExecuteNonQuery();
cnn.Close();
{
Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "alert('Your. - " + ddlCommentType.SelectedItem.ToString() + " has been submitted successfully.');", true);
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "alert('Only Images ('.JPG, .PNG .BMP and .pdf format') can be uploaded')");
}
}
}