using System.Data.SqlClient; public partial class radiobutton : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Visible = false; } protected void Button1_Click(object sender, EventArgs e) { if((RadioButtonList1.SelectedValue=="")||(TextBox1.Text=="")||(DropDownList1.Text=="Select")) { Label1.Visible = true; } else { SqlConnection con = new SqlConnection(); con.ConnectionString = "Initial Catalog=dev; Data Source=.; Integrated Security=true"; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "insert into inserttest values('" + RadioButtonList1.SelectedItem.Text + "','" + TextBox1.Text + "','" + DropDownList1.SelectedValue + "','" + CheckBox1.Checked + "')"; cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); Response.Redirect(Request.Url.AbsolutePath); RadioButtonList1.Text = ""; TextBox1.Text = ""; DropDownList1.Text = "Select"; Label1.Visible = false; } } }
//to avaoid pressing F5 key document.onkeydown = function() { if(event.keyCode==116) { event.keyCode=0; event.returnValue = false; } } //to avoid refresh, using context menu of the browser document.oncontextmenu = function() {event.returnValue = false;}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)