2010-12-07 31 views
0

我得到生成錯誤,「表達式不是方法」爲下面的代碼ASP.NET表達式不是方法

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
      'LOOKUP SKU DATA ON BLUR 
      Dim lookup As String = ClientScript.GetPostBackEventReference(txtSKU, "", False) 
      txtSKU.Attributes.Add("onblur", "doLookup()") 

      If Not IsPostBack Then 
       If txtSKU.Text <> "" Then 
        lookup() '*************the error points to this line******* 
       End If 
      End If 

    End Sub 

    Protected Sub btnLookup_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles btnLookup.Command 
      lookup() 
    End Sub 

    Protected Sub lookup() 
      'BLAH BLAH BLAH 
    End Sub 

任何想法或建議?

回答

3

那是因爲你已經聲明與方法同名的局部變量:

Dim lookup As String = ClientScript.GetPostBackEventReference(txtSKU, "", False) 

總之,不這樣做:)只需重命名變量,它應該是罰款。

+0

謝謝!我應該自己抓住了!最好再喝一杯咖啡! – s15199d 2010-12-07 15:57:51

1

你已經在相同的方法和查找函數中聲明瞭查找字符串。

更改字符串的名稱,它將起作用。