2017-11-18 136 views
-2

我在我的aspx頁面中有一個jquery文檔準備好函數。 我想調用它,或者從後面的代碼運行這個jquery文檔就緒函數。如何從後面的代碼調用jquery函數(document.ready函數)

我該怎麼做?或如何可以寫一個jQuery函數類似

例子:

function abc() 
{ 
    a + b = c 
} 

,並呼籲從後面的代碼

+1

爲什麼你想這樣做?它可以完成,但它根本不容易。 – CodingYoshi

+0

jquery本質上就是javascript。你可以使用[這裏列出的方法](https://stackoverflow.com/questions/5731224/calling-javascript-function-from-codebehind) – Serendipity

+0

我試過上面的方法,因爲你提到使用ScriptManager.RegisterClientScriptBlock調用javascript函數,我我能夠進入JavaScript的功能,但它不幫助進入jquery文檔準備功能。 –

回答

-1
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> 
+0

檢查此鏈接的jquery和html「http://bytesare.us/cms/index.php/demo-apps/html-table-with-fixed-header-and-first-column」 –

+0

在按鈕單擊我有創建了一個函數來調用數據庫中的數據作爲數據表,並且我正在使用循環來打印包含數據表數據的表。然後,我打電話給jquery修復標題和第一個coloum修復,當我們scrool horizo​​ndal和垂直。檢查這個鏈接「http://bytesare.us/cms/index.php/demo-apps/html-table-with-fixed-header-and-first-column」 –

-1

這個jQuery ABC功能在下面的代碼

ClientScript. RegisterStartupScript(this.GetType(), "blah", "YourJsFunction();", true); 

頁面加載事件中使用按鈕點擊事件使用下面的代碼

ClientScript.RegisterClientScriptBlock(this.GetType(), "blah", "YourJsFunction();", true); 
+0

function myFun(){ alert(「KKKKKKKKKKkkkkkkkkk」); jQuery的(文件)。就緒(函數($){ 警報( 「進入運作模式」); $( '#myDemoTable')fixedHeaderTable({ altClass: '奇', 頁腳:真實, 。 fixedColumns:1 }); }); } –

+0

我能夠進入myFun javascript函數。通過使用RegisterClientScriptBlock。但它沒有幫助進去的jQuery(文件)。就緒(函數($){ –

+0

現在我希望你明白我的問題 –

相關問題