C# 服务器标签don';我不能在OnClientClick中工作
服务器标签在这里不起作用。我花了1-2个小时想办法让这一切顺利,但什么也没找到 服务器标记适用于:C# 服务器标签don';我不能在OnClientClick中工作,c#,asp.net,javascript,server-tags,C#,Asp.net,Javascript,Server Tags,服务器标签在这里不起作用。我花了1-2个小时想办法让这一切顺利,但什么也没找到 服务器标记适用于: <asp:button runat="server" Text="Save as" OnClick="btnSave_click" OnClientClick="if(!Check('<% # tb.ClientID %>')) return false; return Object();" CausesValidation="false"></asp:butto
<asp:button runat="server" Text="Save as" OnClick="btnSave_click"
OnClientClick="if(!Check('<% # tb.ClientID %>')) return false; return Object();"
CausesValidation="false"></asp:button>
<asp:TextBox runat="server" ID="tb"></asp:TextBox>
在javascript中,首先应该是:
<OnClientClick="JSFunc();"
<script type="text/javascript">
function JSFunc()
{
var el = document.getElementById('<% # tb.ClientID %>');
//some actions with el here
}
</script>
注意“=”符号
其次,如果您希望内联加载,还必须在页面上调用DataBind()
方法。在javascript中,首先应该:
<OnClientClick="JSFunc();"
<script type="text/javascript">
function JSFunc()
{
var el = document.getElementById('<% # tb.ClientID %>');
//some actions with el here
}
</script>
注意“=”符号
其次,如果希望内联执行,还必须在页面加载上调用DataBind()
方法。使用表达式生成器,不需要调用DataBind,而且可以很容易地内联
请参见使用表达式生成器,您不需要调用数据绑定,并且可以很容易地将其内联
看