I have disabled a button in javascript. On page load I need to enable it again.
我在javascript中禁用了一个按钮。在页面加载时,我需要再次启用它。
This is my code in script.
这是我的脚本代码。
$(document).ready(
function () {
document.getElementById("<%=btnsubmit.ClientID%>").disabled = true;
});
In code behind,I am enabling it
在代码背后,我正在启用它
protected void Page_Load(object sender, EventArgs e)
{
btnsubmit.Enabled = true;
}
but its not enabled.
但它没有启用。
Can anyone please help?
有人可以帮忙吗?
5 个解决方案
#1
5
The server side event Page_Load
always run first..So you are enabling the button first and then disabling it in the clientside $(document).ready
..
服务器端事件Page_Load总是首先运行。因此,您首先启用该按钮,然后在客户端$(文档).ready中禁用它。
I don't know what is your goal.But you can solve the problem by..
我不知道你的目标是什么。但是你可以通过......解决问题。
protected void Page_Load(object sender, EventArgs e)
{
btnsubmit.Enabled = false;
}
Javascript..
$(document).ready(
function () {
document.getElementById("<%=btnsubmit.ClientID%>").disabled = false;
});
Refer this link for extra reading...
请参阅此链接以获取额外阅读......
#2
0
Try with btnsubmit.disabled = false;
尝试使用btnsubmit.disabled = false;
like
protected void Page_Load(object sender, EventArgs e)
{
btnsubmit.disabled = false;
}
#3
0
Page load runs when the page is rendered on the server - First.
After the page gets rendered on the server it gets to the client and then the js starts running. Your page load assignment gets overridden on the clients end.
页面加载在服务器上呈现页面时运行 - 首先。页面在服务器上呈现后,它会到达客户端,然后js开始运行。您的页面加载分配在客户端被覆盖。
You can do both on the server(enable\disable).
您可以在服务器上执行这两项操作(启用\禁用)。
delete this:
$(document).ready(
function () {
document.getElementById("<%=btnsubmit.ClientID%>").disabled = true;
});
And use this:
并使用这个:
protected void Page_Load(object sender, EventArgs e)
{
if(blah blah blah)
btnsubmit.Enabled = true;
else
btnsubmit.Enabled = false;
}
#4
0
try this out , using jQuery
尝试使用jQuery
$(document).ready(function(){
$('#buttonID/.buttonClass').removeAttr('disabled');
});
and through javascript use
并通过javascript使用
document.getElementById("buttonid").setAttribute("disabled", false);
#5
0
You can use asp button in front end. And choose enable false to disabled it.
你可以在前端使用asp按钮。并选择启用false以禁用它。
<asp:Button id="btnName" runat="server" Text="Add" Enabled="false"/>
Then you can enable it in server side.
然后您可以在服务器端启用它。
btnName.Enabled = true;
#1
5
The server side event Page_Load
always run first..So you are enabling the button first and then disabling it in the clientside $(document).ready
..
服务器端事件Page_Load总是首先运行。因此,您首先启用该按钮,然后在客户端$(文档).ready中禁用它。
I don't know what is your goal.But you can solve the problem by..
我不知道你的目标是什么。但是你可以通过......解决问题。
protected void Page_Load(object sender, EventArgs e)
{
btnsubmit.Enabled = false;
}
Javascript..
$(document).ready(
function () {
document.getElementById("<%=btnsubmit.ClientID%>").disabled = false;
});
Refer this link for extra reading...
请参阅此链接以获取额外阅读......
#2
0
Try with btnsubmit.disabled = false;
尝试使用btnsubmit.disabled = false;
like
protected void Page_Load(object sender, EventArgs e)
{
btnsubmit.disabled = false;
}
#3
0
Page load runs when the page is rendered on the server - First.
After the page gets rendered on the server it gets to the client and then the js starts running. Your page load assignment gets overridden on the clients end.
页面加载在服务器上呈现页面时运行 - 首先。页面在服务器上呈现后,它会到达客户端,然后js开始运行。您的页面加载分配在客户端被覆盖。
You can do both on the server(enable\disable).
您可以在服务器上执行这两项操作(启用\禁用)。
delete this:
$(document).ready(
function () {
document.getElementById("<%=btnsubmit.ClientID%>").disabled = true;
});
And use this:
并使用这个:
protected void Page_Load(object sender, EventArgs e)
{
if(blah blah blah)
btnsubmit.Enabled = true;
else
btnsubmit.Enabled = false;
}
#4
0
try this out , using jQuery
尝试使用jQuery
$(document).ready(function(){
$('#buttonID/.buttonClass').removeAttr('disabled');
});
and through javascript use
并通过javascript使用
document.getElementById("buttonid").setAttribute("disabled", false);
#5
0
You can use asp button in front end. And choose enable false to disabled it.
你可以在前端使用asp按钮。并选择启用false以禁用它。
<asp:Button id="btnName" runat="server" Text="Add" Enabled="false"/>
Then you can enable it in server side.
然后您可以在服务器端启用它。
btnName.Enabled = true;