本文介绍了使用asp.net javascript函数禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题想禁用按钮,下面是我的javascript函数:
<脚本类型=文/ JavaScript的>
VAR DisableButton =功能(){
的document.getElementById(<%= LoginButton.ClientID%GT;)。禁用= TRUE;
};
VAR EnableButton =功能(){
的document.getElementById(<%= LoginButton.ClientID%GT;)。禁用= FALSE; };
< / SCRIPT>
而这正是该按钮位于
< ASP:登录ID =LoginUser=服务器的EnableViewState =假RenderOuterTable =false的>
<&LayoutTemplate模板GT; <% - 在这里的一些元素:文本框,等等 - %GT; < DIV>
< p =类提交按钮>
< ASP:按钮的ID =LoginButton=服务器的CommandName =登录文本=登录
的ValidationGroup =LoginUserValidationGroup/>
&所述; / P>
< / DIV>
< / LayoutTemplate模板>
< / ASP:登录>
它的其他页面的工作..但在这里,我得到这个错误
描述:
此请求提供服务所需资源的编译过程中出现错误。
请检查下列特定错误详细信息并适当地修改源$ C $ C。编译器错误信息:
CS1061:'System.Web.UI.WebControls.Login'不包含一个定义
对于LoginButton',没有扩展方法'LoginButton接受式的第一个参数
System.Web.UI.WebControls.Login'可以找到(是否缺少using指令或程序集引用?)
源错误:
的document.getElementById(<%= LoginButton.ClientID%GT;)。禁用= TRUE;
此外,我从谷歌验证码事件调用这些函数:
< DIV ID =ASD级=G-验证码数据回调=EnableButton数据过期回调=DisableButton数据sitekey =site_key >
我究竟做错了什么?我错过了什么?
解决方案
<脚本类型=文/ JavaScript的>
功能DisableButtons()
{
的document.getElementById(<%= Button2.ClientID%GT;)。禁用= TRUE;
的document.getElementById(<%= Button3.ClientID%GT;)。禁用= TRUE;
返回true;
}
< / SCRIPT>
< ASP:按钮的ID =Button1的=服务器文本=按钮的OnClientClick =返回DisableButtons()/>
< ASP:按钮的ID =Button2的=服务器文本=按钮/>
< ASP:按钮的ID =按钮3=服务器文本=按钮/>
和更多信息使用
i am having a problem trying to disable a button, here is my javascript function:
<script type="text/javascript">
var DisableButton = function () {
document.getElementById("<%= LoginButton.ClientID %>").disabled = true;
};
var EnableButton = function () {
document.getElementById("<%= LoginButton.ClientID %>").disabled = false; };
</script>
and this is where the button is located
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
<LayoutTemplate>
<%-- some elements here: text boxes, etc --%>
<div>
<p class="submitButton">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In"
ValidationGroup="LoginUserValidationGroup"/>
</p>
</div>
</LayoutTemplate>
</asp:Login>
it worked in the other pages.. but here, i get this 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:
CS1061: 'System.Web.UI.WebControls.Login' does not contain a definition
for 'LoginButton' and no extension method 'LoginButton' accepting a first argument of type
'System.Web.UI.WebControls.Login' could be found (are you missing a using directive or an assembly reference?)
Source Error:
document.getElementById("<%= LoginButton.ClientID %>").disabled = true;
additionally, i am calling these functions from google recaptcha events:
<div id="asd" class="g-recaptcha" data-callback="EnableButton" data-expired-callback="DisableButton" data-sitekey="site_key">
What am i doing wrong here? Did i miss something?
解决方案
<script type="text/javascript">
function DisableButtons()
{
document.getElementById ("<%=Button2.ClientID %>").disabled = true;
document.getElementById ("<%=Button3.ClientID %>").disabled = true;
return true ;
}
</script>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return DisableButtons()" />
<asp:Button ID="Button2" runat="server" Text="Button" />
<asp:Button ID="Button3" runat="server" Text="Button" />
And more information use Instantly disable Button on click
Disabling Buttons within C# method
这篇关于使用asp.net javascript函数禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!