没有为动态链接按钮触发click事件。 [英] The click event is not firing for a dynamic link button.
本文介绍了没有为动态链接按钮触发click事件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道用户应用的作业的ID。最初,用户点击下拉列表以根据他/她的搜索条件查看作业。之后,用户可以单击页面上显示的任何作业。为此,我有链接按钮。但链接按钮不会在click事件上触发。请帮帮我。
Hi,
I have a requirement to know the id of a job that is applied by the user. Here initially the user clicks on a drop down list to view jobs based on his/her search criteria. After that the user can click on any of the jobs that is displayed on the page. For that i have link buttons. But the link buttons are not firing on the click event. Please help me.
SqlCommand cmd = new SqlCommand();
int ID = 0;
try
{
cmd.Connection = con;
cmd.CommandText = "SELECT TOP(10) s_JobDesignation,s_JobDescription,s_NoOfVacancies,s_DatePosted,s_JobCategoryID FROM [OfinityJobSearch].[dbo].[tx_ListOfJobs] WHERE s_IndustryName='" + industryName + "' ORDER BY s_JobId ASC ";
cmd.CommandType = CommandType.Text; if (cmd.Connection.State == ConnectionState.Closed)
cmd.Connection.Open();
using (SqlDataReader reader = cmd.ExecuteReader()) {
if (reader.HasRows)
{
while (reader.Read())
{
JobDesignation = reader.GetString(0);
JobDescription = reader.GetString(1);
NoOfVacancies = Convert.ToString(reader.GetInt32(2));
DatePosted = Convert.ToString(reader.GetDateTime(3)).Replace("00:00:00", "");
jobId = reader.GetString(4);
int tblRows = 1;
int tblCols = 1;
Table tbl = new Table();
PlaceHolder1.Controls.Add(tbl);
for (int i = 0; i < tblRows; i++)
{
readerrowcount = readerrowcount + 1;
TableRow tr = new TableRow();
tr.CssClass = "rowStyle1";
for (int j = 0; j < tblCols; j++)
{
TableCell tc = new TableCell();
tc.CssClass = "cellStyle1";
System.Web.UI.WebControls.Label txtBox = new System.Web.UI.WebControls.Label();
txtBox.Text = "Job ID:" + jobId + "<br />" + "Job Designation:" + JobDesignation + "<br />" + "Job Description:" + JobDescription + "<br />" + "Vacancies:" + NoOfVacancies + "<br />" + "Ad Posted On:" + DatePosted + "<br />"+"";
tc.Controls.Add(txtBox);
tr.Cells.Add(tc);
System.Web.UI.WebControls.LinkButton lbView = new System.Web.UI.WebControls.LinkButton();
lbView.Text = "<br />" + "Apply for this Job";
lbView.Click += new EventHandler(lbView_Click);
lbView.OnClientClick = "return RedirectTo('" + id + "')";
tc.Controls.Add(lbView);
tr.Cells.Add(tc);} tbl.Rows.Add(tr);
}
ViewState["dynamictable"] = true;
} reader.NextResult();
}
}
}
这里lbView.Click事件根本没有触发。你能告诉我哪里出错了吗?
Here the lbView.Click event is not firing at all. Can you tell me where i went wrong?
推荐答案
Try it in JQuery...Write the below code with in document ready function of jQuery.
(document).ready( function (){
(document).ready(function(){
( #id_of_dynamic_link_button)。live( 点击, function (){
alert( Link_return按钮成功激活);
});
("#id_of_dynamic_link_button").live("click", function () { alert("Link_return button fired successfully"); });
});
});
这篇关于没有为动态链接按钮触发click事件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文