I have a dropdownlist populated by my database and a button on my page1, now when I click the button page2 will popup which contains of 1 textbox and 2 buttons, if I enter a value in my textbox and click the save button, it'll save on my database and when i click the close button, popup will close then what I want is my dropdown on page1 will reload (without reloading the entire page) in order to get the value that I entered in popup window. This is what I have got so far:
Page1:
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "window.open('Entry.aspx','','height=200,width=650');return false");
}
Page2:
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
if (txtfname.Text == String.Empty)
{
lblname.Text = "First Name Required";
lblname.Visible = true;
}
else if (txtlname.Text == String.Empty)
{
lbllname.Text = "Last name Required";
lbllname.Visible = true;
}
else
{
SqlConnection con = new SqlConnection("Data Source=GATE-PC\\SQLEXPRESS;Initial Catalog=dbProfile;Integrated Security=True");
SqlCommand cmd = new SqlCommand("insert", con);
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@Lname", txtlname.Text);
cmd.Parameters.AddWithValue("@Mname", txtmname.Text);
cmd.Parameters.AddWithValue("@Fname", txtfname.Text);
cmd.Parameters.AddWithValue("@checkbox1", CheckBox1.Checked);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
con.Open();
cmd.ExecuteNonQuery();
MessageBox("successfully saved!");
clear();
}
}
catch (Exception exe)
{
throw exe;
}
}
protected void btnClose_Click(object sender, EventArgs e)
{
Response.Write("window.opener.location.reload();self.close();");
}
Someone kindly help me with this. i am using asp.net with c#. Thanks.