我正在一个aspx中的网站上工作,我需要弹出一个窗口。我有一个弹出,我想在网站中使用它。 我的问题是当我使用弹出在我的imagebutton,比弹出打开,但button_click事件不会触发。我只想让我的弹出窗口打开,按钮点击事件也能正确触发。 请帮我。我在JavaScript中很弱。 我的代码是在这里: -当弹出窗口打开时,按钮点击事件不会被触发
Asp.Net代码: -
<script type="text/javascript">
$("[id*=ImageButton1]").live("click", function() {
$("#modal_dialog").dialog({
buttons: {
Close: function() {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
</script>
<asp:ImageButton ID="ImageButton1" style="margin-left:7px;" ImageUrl="~/button.png" runat="server"
onclick="ImageButton1_Click"></asp:ImageButton>
和我的C#代码是在这里: -
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LPSConnection"].ConnectionString.ToString());
con.Open();
int id = Int32.Parse(Request.QueryString["id"].ToString());
SqlDataReader rd = new SqlCommand("Select Booked from ExpertChat where id=" + id, con).ExecuteReader();
rd.Read();
int x = Int32.Parse(rd["Booked"].ToString());
rd.Close();
if (x == 0)
{
SqlCommand cmd = new SqlCommand("Update ExpertChat set Booked=1 where id=" + id, con);
cmd.ExecuteNonQuery();
SqlCommand mRead1 = new SqlCommand("insert into chat (ExpertName,UserName,rate) Values ('" + Label1.Text + "','" + Session["SName"] + "','" + Label5.Text + "')", con);
mRead1.ExecuteNonQuery();
SqlDataReader mRead4;
mRead4 = new SqlCommand("Select top 1 id from Chat where ExpertName='" + Label1.Text + "' order by id Desc", con).ExecuteReader();
mRead4.Read();
int x1;
x1 = Int32.Parse(mRead4["id"].ToString());
mRead4.Close();
wait(x1);
}
else
{
Response.Redirect("ExpertMail.aspx?id=" + id);
}
}
什么版本的jQuery您使用的是? live()已被弃用,并在更高版本中删除! – adeneo
正如我告诉我,我在JavaScript弱,所以我不知道它的版本 – yash
任何人都可以给我正确的想法? – yash