如何从后面的代码调用jquery函数(document.ready函数)
我在我的aspx页面中有一个jquery文档准备好函数。 我想调用它,或者从后面的代码运行这个jquery文档就绪函数。如何从后面的代码调用jquery函数(document.ready函数)
我该怎么做?或如何可以写一个jQuery函数类似
例子:
function abc()
{
a + b = c
}
,并呼吁从后面的代码
protected void btnSearch_Click(object sender, EventArgs e)
{
if (Validate1())
{
objELItemMaster.Item_CategoryCode = Convert.ToInt32(ddlItemType.SelectedValue);
DataTable BranchStockDetails = objBLItemMaster.GetBranchItemDetails(objELItemMaster);
int rows = BranchStockDetails.Rows.Count;
int cols = BranchStockDetails.Columns.Count;
html1 += "<div class=\"outerbox\"><div class=\"innerbox\"><table class=\"bluetable\" id=\"myDemoTable\" cellpadding=\"0\" cellspacing=\"0\"> <thead> <tr>";
for (int i = 0; i < cols; i++)
{
html1 += "<th>" + BranchStockDetails.Columns[i].ColumnName.ToString() + "</th>";
}
html1 += "</tr></thead><tbody>";
for (int j = 0; j < rows; j++)
{
html1 += " <tr>";
for (int k = 0; k < cols; k++)
{
html1 += "<td>" + BranchStockDetails.Rows[j][k].ToString() + "</td>";
}
html1 += "</tr>";
}
html1 += "</tbody></Table></div></div>";
Datatable1.InnerHtml = html1;
ScriptManager.RegisterStartupScript(this, this.GetType(), "name", "myFun();", true);
}
}
public bool IsNumeric(string input)
{
int number;
return int.TryParse(input, out number);
}
private void Alert(string Message)
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "err_msg", "alert('" + Message + "');", true);
}
private bool Validate1()
{
if (Convert.ToInt32(ddlItemType.SelectedItem.Value) == 0)
{
Alert("Please select a category of product.");
ddlItemType.Focus();
return false;
}
return true;
}
<script type="text/javascript">
function myFun() {
$('#myDemoTable').fixedHeaderTable({
altClass: 'odd',
footer: true,
fixedColumns: 1
});
}
</script>
检查此链接的jquery和html“http://bytesare.us/cms/index.php/demo-apps/html-table-with-fixed-header-and-first-column” –
在按钮单击我有创建了一个函数来调用数据库中的数据作为数据表,并且我正在使用循环来打印包含数据表数据的表。然后,我打电话给jquery修复标题和第一个coloum修复,当我们scrool horizondal和垂直。检查这个链接“http://bytesare.us/cms/index.php/demo-apps/html-table-with-fixed-header-and-first-column” –
这个jQuery ABC功能在下面的代码
ClientScript. RegisterStartupScript(this.GetType(), "blah", "YourJsFunction();", true);
页面加载事件中使用按钮点击事件使用下面的代码
ClientScript.RegisterClientScriptBlock(this.GetType(), "blah", "YourJsFunction();", true);
function myFun(){ alert(“KKKKKKKKKKkkkkkkkkk”); jQuery的(文件)。就绪(函数($){ 警报( “进入运作模式”); $( '#myDemoTable')fixedHeaderTable({ altClass: '奇', 页脚:真实, 。 fixedColumns:1 }); }); } –
我能够进入myFun javascript函数。通过使用RegisterClientScriptBlock。但它没有帮助进去的jQuery(文件)。就绪(函数($){ –
现在我希望你明白我的问题 –
为什么你想这样做?它可以完成,但它根本不容易。 – CodingYoshi
jquery本质上就是javascript。你可以使用[这里列出的方法](https://stackoverflow.com/questions/5731224/calling-javascript-function-from-codebehind) – Serendipity
我试过上面的方法,因为你提到使用ScriptManager.RegisterClientScriptBlock调用javascript函数,我我能够进入JavaScript的功能,但它不帮助进入jquery文档准备功能。 –