简体   繁体   English

带有参数的JavaScript不能从后面的代码中调用

[英]JavaScript with parameters not being called from code behind

Hello I'm still pretty new to JavaScript and I am trying to call a function with multiple parameters from the codebehind. 您好,我对JavaScript还是很陌生,我正尝试从背后的代码中调用带有多个参数的函数。 I believe I am calling it wrong because I cant even hit the degubber on my javascript file. 我相信我说错了,因为我什至无法在我的javascript文件上点击调试程序。 The function is supposed to take those parameters and set the textboxes and such to those values. 该功能应该采用这些参数,并将文本框等设置为这些值。

Here is my codebehind: 这是我的代码背后:

RadScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "createEditAccount('" + ar2.Received_Date +"','" + ar2.Deposited_Date + "','" +
                                    ar2.Company_Name + "','" + ar2.Check_Amount + "','" + ar2.Check_Number + "','" +
                                    ar2.Description_ + "','" + arb.Breakdown_Amount  +
                                     "','" + arb.Account_Number + "','" + arb.Breakdown_Amount + "','" + arb.Notes + ");", true);

Here is my JavaScript Function: 这是我的JavaScript函数:

function createEditAccount(ReceivedDate, DepositedDate, tbCompanyName, tbCheckAmount, tbCheckNum, tbDesc, cbResultsBreak, cbResultAcctNum, tbResultBreak, tbResultNotes) {
$("#EditAccount").modal('toggle');
$telerik.findControl(document, "ReceiveDate").value = ReceivedDate;
$telerik.findControl(document, "DepositDate").value = DepositedDate;
$telerik.findControl(document, "tbCompanyName").value = tbCompanyName;
$telerik.findControl(document, "tbCheckAmount").value = tbCheckAmount;
$telerik.findControl(document, "tbCheckNum").value = tbCheckNum;
$telerik.findControl(document, "tbDesc").value = tbDesc;
$telerik.findControl(document, "cbResultsBreak").value = cbResultsBreak;
$telerik.findControl(document, "cbResultAcctNum").value = cbResultAcctNum;
$telerik.findControl(document, "tbResultBreak").value = tbResultBreak;
$telerik.findControl(document, "tbResultNotes").value = tbResultNotes;
$("#MainContent_subType").val("new");

} }

You can pass an additional parameter to the RegisterClientStartupScript method call to indicate that scriptTags need to be added. 您可以将其他参数传递给RegisterClientStartupScript方法调用,以指示需要添加scriptTags。

Page.ClientScript.RegisterStartupScript(
    GetType(), 
    "MyKey", 
    "Myfunction();", 
    true);

Hope this helps. 希望这可以帮助。

问题是我需要使用ScriptManager.RegisterClientScriptBlock()因为我正在使用模式,并且此方法用于ajax回发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM