if user insert data and click on "SUBMIT Button" then popup msg come with "YES" or "NO" msg
<%@ Page Language="C#" AutoEventWireup="true" Codefile="It_Comp.aspx.cs" Inherits="OCMS.It_Comp" %>
<script type="text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to save data?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
<body class="auto-style21">
<form id="form1" runat="server">
<table width="100%" height="30" border="1" cellpadding="1" cellspacing="1" align="center" bgcolor="#99CCCC" bordercolor="#000000">
<tr bgcolor="#3090C7">
<td class="auto-style4"><img src="img/m1.png" class="auto-style1" />
</td>
<th colspan="5" class="auto-style3">
<u><span class="auto-style8">
<font color="white" class="auto-style9"><strong class="auto-style12">COMPLAINT MANAGEMENT SYSTEM</strong></font></span></u>
<marquee attribute_name="attribute_value" class="auto-style24" >For any assistance please contact 3126 or mail to munplit@ntpc.co.in</marquee>
</th>
<th class="auto-style3">
Date:<br /> <asp:Label ID="LabelD" runat="server" Text="" CssClass="auto-style24"></asp:Label><br />
<asp:Label ID="lblIP" runat="server" Font-Bold="true" Font-Size="Large" ForeColor="#FFFF12" CssClass="auto-style18"/><br />
<br />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CssClass="auto-style7" CausesValidation="false">BACK</asp:LinkButton>
<br />
</th>
</tr>
</table>
<table width="100%" height="30" border="1" cellpadding="1" cellspacing="1" align="center" bgcolor="#99CCCC" bordercolor="#000000">
<tr>
<td><h4 class="auto-style17">COMPLAINT TYPE</h4>
<asp:TextBox ID="ReadOnlyTextBox" runat="server"
ReadOnly="True">IT COMPLAINT</asp:TextBox>
</td>
<td>
<h4>COMPLAINT CATEGORY</h4>
<select name="cat" size="1" onchange="redirect(this.options.selectedIndex);SetMessage();">
<option value="0" selected="selected">Select a category</option>
<option value=""></option>
<option value="--">-----------------------------------------</option>
<option value="PC -">PC</option>
<option value="Printer -">Printer</option>
</select>
</td>
<td>
<div name="dvPrinter" style="display: none;">
<h4>PRINTER TYPE:</h4>
<select name="printer" size="1" onchange="SetMessage()">
<option value="0" selected="selected">Select a category</option>
<option value=""></option>
<option value="--">-----------------------------------------</option>
<option value="Personal -">Personal</option>
<option value="Common -">Common</option>
</select>
</div>
</td>
<td class="auto-style26">
<h4>TYPE</h4>
<select name="type" size="1" onchange="SetMessage()"></select>
</td>
<td>
<div name="Location">
<h4>LOCATION:</h4>
<select name="Location" size="1" onchange="SetMessage()" class="auto-style20">
<option value="0" selected="selected">Select a Location</option>
<option value=""></option>
<option value="--">-----------------------------------------</option>
<option value="H-type">H-type</option>
</select>
</div>
<td>
<div name="room">
<h4>Building/Room/Hall:</h4>
<asp:TextBox ID="room" runat="server" onchange="SetMessage()" placeholder="room/hall"></asp:TextBox>
</div>
</td>
<td>
<h4>Image File:(Only image File (jpg,png))</h4>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr bgcolor="#3090C7">
<u>
<font color="#FFFF12" >
<h3 align="left" >IT Complaint box:  
</font>
<strong>
<font color="white" >
Emp. Id:
<asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>  
Mob.No:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>  
<asp:Label ID="txtrowid" runat="server" Text=""></asp:Label>
</font>
</strong>
</h3>
</u></tr>
<table width="100%" height="30" border="1" cellpadding="1" cellspacing="1" align="center" bgcolor="#99CCCC" bordercolor="#000000">
<br />
<tr>
<td width="120" scope="col">
<center><b>COMPLAINT MESSAGE </b></center>
</td>
<td>
<asp:TextBox runat="server" ID="str" TextMode="Multiline" Columns="20" Name="S1" Rows="2" CssClass="auto-style10" Height="140px" Width="1154px"></asp:TextBox><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server" ErrorMessage="**Complaint message Can't be blank**" ControlToValidate="str" ForeColor="Red"></asp:RequiredFieldValidator>
<center><asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" CssClass="auto-style15" Height="26px" Width="83px" OnClientClick="Confirm()" ></asp:Button></center>
</td>
</tr>
</table>
<div id="dialog" style="display: none"></div>
</div>
</table>
</form>
protected void Button1_Click(object sender, EventArgs e)
{
string employeeId = lblName.Text.Trim();
string message = str.Text.Trim();
string ReadOnly = ReadOnlyTextBox.Text.Trim();
string COMP_LODGE_DATE = DateTime.Now.ToString("yyy/dd/mm");
string image = "";
if (FileUpload1.HasFile)
{
string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
if (!Directory.Exists(Server.MapPath("~/Images")))
{
Directory.CreateDirectory(Server.MapPath("~/Images"));
}
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Images/") + fileName);
image = "~/Images/" + fileName;
}
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string query = "insert_ittest1";
using (SqlConnection con = new SqlConnection(conString))
{
SqlCommand cmd = new SqlCommand(query);
cmd.Parameters.AddWithValue("@EMP_ID", employeeId);
cmd.Parameters.AddWithValue("@COMP_MESSAGE", message);
cmd.Parameters.AddWithValue("@Comp_type", ReadOnly);
cmd.Parameters.AddWithValue("@COMP_LODGE_DATE", COMP_LODGE_DATE);
cmd.Parameters.AddWithValue("@image", image);
cmd.Parameters.Add("@COMP_ID", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
con.Dispose();
}
}