问题
I'm trying to follow the PageMethods example found here.
However, I get an error when trying to call $get('Label1')
.
Since, Label1 is an asp:Label, it works if I call $get() with the ClientID. Yet, the example is using the actual ID. Is there a way to use $get() with the actual ID?
回答1:
Well that depends what the label is contained in. In some controls it will be Label1 and work, in others it won't be. Don't chance it.
So on a simple page it gets rendered as Label1:
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Text="test" runat="server"></asp:Label>
</div>
</form>
On a more complex page it will be rendered as something else (ctl00_head_Label1 in my case), using a masterpage as an example:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Label ID="Label1" Text="test" runat="server"></asp:Label>
</asp:Content>
来源:https://stackoverflow.com/questions/982662/get-and-find-with-ajax-net