单击事件图像按钮未触发 [英] click event of image button is not firing
本文介绍了单击事件图像按钮未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< table >
< tr >
< td class = popuplbltdwithpadding >
< ; asp:ImageButton ID = btnsaveparameter
ImageUrl = 〜/ images / HMS Buttons / SaveHMS.jpg runat = server
onclick = btnsaveparameter_Click1 / >
< / td >
< td class = popuplbltdwithpadding >
< asp:ImageButton ID = ImageButton1 runat = server
ImageUrl = 〜/ images / HMS Buttons / Close.jpg / >
< / td >
< / tr >
< / table >
protected void btnsaveparameter_Click1( object sender,ImageClickEventArgs e)
{
// ImageButton b =(ImageB utton)sender;
// GridViewRow row =(GridViewRow)sender;
// int rowIndex = row.RowIndex;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chk =(CheckBox)row.FindControl ( chkSelect);
if (chk.Checked)
{
string ParameterId = grdcareplan.DataKeys [ 0 ]。Value.ToString();
MySqlConnection StrConnection = null ;
MySqlCommand StrCommand = null ;
try
{
StrConnection = new MySqlConnection ();
StrConnection.ConnectionString = StrConn;
StrConnection.Open();
StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText = Insert_Parameter_Name;
StrCommand.Connection = StrConnection;
// StrCommand.Parameters.AddWithValue(_ ParameterName,dropdowndisease。 SelectedItem.Text);
StrCommand.Parameters.AddWithValue( _ DiseaseId ,Convert.ToInt32(ViewState [ DiseaseId]));
StrCommand.Parameters.AddWithValue( _ ParameterId,ParameterId);
StrCommand.Parameters.AddWithValue( _ Branch_Id,Convert.ToInt32(Session [ Branchid]));
StrCommand.Parameters.AddWithValue( _ Tenant_Id,Convert.ToInt32(Session [ Tenantid]));
StrCommand.Parameters.AddWithValue( _ Patient_Id,Convert.ToInt32(Session [ DiagnosisClickId]));
// StrCommand.Parameters.AddWithValue(_ Submit_Date,DateTime。现在);
StrCommand.ExecuteNonQuery();
BindCarePlan();
ModalPopupExtender1.Show();
Biomade.Visible = true ;
}
catch (Exception ex)
{
obj.InfoEntry(DateTime.Now + < span class =code-string> + BtnSave1_Click + + AccountBalance.aspx + + ex.Message, );
obj.InfoEntry(DateTime.Now + + ex.StackTrace, );
会话[ strerrormsg] = DateTime.Now + + BtnSave1_Click + + AccountBalance.aspx + + ex.Message;
会话[ strerrortrace] = DateTime.Now + + ex.StackTrace;
Response.Redirect( ErrorPage.aspx);
}
finally
{
StrConnection.Close();
StrConnection.Dispose();
ModalPopup_Items.Show();
}
}
}
}
解决方案
我的代码并更改它
< asp:ImageButton ID = btnsaveparameter
ImageUrl = 〜/ images / HMS Buttons / SaveHMS.jpg runat = server
OnClick = btnsaveparameter_Click1 / >
它会起作用
我希望你的问题解决,如果不给我你的评论
按钮中没有Onclick事件标记
< asp:imagebutton id = btnsaveparameter imageurl = 〜/ images / HMS Buttons / SaveHMS .jpg runat = server onclick = btnsaveparameter_Click1 xmlns:asp = #unknown / > 跨度>
<table >
<tr>
<td class="popuplbltdwithpadding">
<asp:ImageButton ID="btnsaveparameter"
ImageUrl="~/images/HMS Buttons/SaveHMS.jpg" runat="server"
onclick="btnsaveparameter_Click1" />
</td>
<td class="popuplbltdwithpadding">
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/images/HMS Buttons/Close.jpg"/>
</td>
</tr>
</table>
protected void btnsaveparameter_Click1(object sender, ImageClickEventArgs e)
{
//ImageButton b = (ImageButton)sender;
//GridViewRow row = (GridViewRow)sender;
//int rowIndex = row.RowIndex;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chk = (CheckBox)row.FindControl("chkSelect");
if (chk.Checked)
{
string ParameterId = grdcareplan.DataKeys[0].Value.ToString();
MySqlConnection StrConnection = null;
MySqlCommand StrCommand = null;
try
{
StrConnection = new MySqlConnection();
StrConnection.ConnectionString = StrConn;
StrConnection.Open();
StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText = "Insert_Parameter_Name";
StrCommand.Connection = StrConnection;
//StrCommand.Parameters.AddWithValue("_ParameterName", dropdowndisease.SelectedItem.Text);
StrCommand.Parameters.AddWithValue("_DiseaseId", Convert.ToInt32(ViewState["DiseaseId"]));
StrCommand.Parameters.AddWithValue("_ParameterId", ParameterId);
StrCommand.Parameters.AddWithValue("_Branch_Id", Convert.ToInt32(Session["Branchid"]));
StrCommand.Parameters.AddWithValue("_Tenant_Id", Convert.ToInt32(Session["Tenantid"]));
StrCommand.Parameters.AddWithValue("_Patient_Id", Convert.ToInt32(Session["DiagnosisClickId"]));
// StrCommand.Parameters.AddWithValue("_Submit_Date", DateTime.Now);
StrCommand.ExecuteNonQuery();
BindCarePlan();
ModalPopupExtender1.Show();
Biomade.Visible = true;
}
catch (Exception ex)
{
obj.InfoEntry(DateTime.Now + " " + "BtnSave1_Click" + " " + "AccountBalance.aspx" + " " + ex.Message, "");
obj.InfoEntry(DateTime.Now + " " + ex.StackTrace, "");
Session["strerrormsg"] = DateTime.Now + " " + "BtnSave1_Click" + " " + "AccountBalance.aspx" + " " + ex.Message;
Session["strerrortrace"] = DateTime.Now + " " + ex.StackTrace;
Response.Redirect("ErrorPage.aspx");
}
finally
{
StrConnection.Close();
StrConnection.Dispose();
ModalPopup_Items.Show();
}
}
}
}
解决方案
i Examing your Code and Change it
<asp:ImageButton ID="btnsaveparameter" ImageUrl="~/images/HMS Buttons/SaveHMS.jpg" runat="server" OnClick="btnsaveparameter_Click1" />
and It will work
I hope Your Problerm will solve if not give me your Reviews
there is no Onclick event in your button Tag
<asp:imagebutton id="btnsaveparameter" imageurl="~/images/HMS Buttons/SaveHMS.jpg" runat="server" onclick="btnsaveparameter_Click1" xmlns:asp="#unknown" />
这篇关于单击事件图像按钮未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文