2010-11-02 27 views
0

我在.js頁面中採用了函數「functionRemainCount()」。我想在.aspx頁面中調用。我已經使用過這樣的代碼,但是它給出的錯誤是函數名不會在當前上下文中退出,因爲它在.js文件中使用。那麼如何調用這個函數呢? 請告訴我。請修改代碼,它給當前上下文中不存在functionRemainCount()的錯誤?

我的代碼是這樣的:

protected void Page_Load(object sender, EventArgs e) 
{ 
    txtNote.Attributes.Add("OnKeyDown", functionRemainCount()); 
      txtNote.Attributes.Add("OnKeyUp", functionRemainCount()); 
} 

回答

1

Try:

txtNote.Attributes.Add("OnKeyDown", "functionRemainCount()"); 
txtNote.Attributes.Add("OnKeyUp", "functionRemainCount()"); 
1

Attributes.Add()有兩個字符串參數。

txtNote.Attributes.Add("OnKeyDown", "functionRemainCount()"); 

在這種情況下,您需要提供一串實際的javascript代碼。

相關問題