嗨,在我的母版页中,我插入了以下 javascript
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<link rel="Stylesheet" type="text/css" href="css/MainStyle.css" />
<script type = "text/javascript">
function ClientItemSelected(sender, e) {
$get("<%=hfCustomerId.ClientID %>").value = e.get_value();
}
在我的内容页面中,我有一个 AutocompleteExtender 这是代码
<asp:TextBox ID="txtCustomer" runat="server">
</asp:TextBox>
<ajx:AutoCompleteExtender ServiceMethod="SearchCustomers" MinimumPrefixLength="2"
CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtCustomer"
ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false" OnClientItemSelected="ClientItemSelected">
</ajx:AutoCompleteExtender>
<asp:HiddenField ID="hfCustomerId" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
但是当我编译时,我收到了这个错误
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request.
Please review the following specific error details and modify your source code
appropriately.
Compiler Error Message: CS0103: The name 'hfCustomerId' does not exist in the current context
Source Error:
Line 11: <script type = "text/javascript">
Line 12: function ClientItemSelected(sender, e) {
Line 13: $get("<%=hfCustomerId.ClientID %>").value = e.get_value();
Line 14:
Line 15: }
有什么我想念的..?