问题描述
您好。
我已阅读很多关于禁用提交按钮的帖子,但我无法获得
这些答案可以解决我的问题。
我有一个服务器端的asp.net按钮,在按钮下我有代码
后面做了一些简单的处理,然后是一个
response.redirect。
当用户点击此按钮时,我希望
按钮立即显示为 ghosted / grayed out / disabled,就像一个
典型的禁用按钮,然后继续执行
处理后面的代码,然后是response.redirect
我尝试过的其中一件事就是在客户端使用javascript
来禁用按钮,但这会产生停止所有代码的效果
在服务器内部运行按钮单击事件处理程序。
有人能解决这个困境吗?
TIA,dnw。
为什么不把它放在DIV中并在点击按钮时隐藏div
-
问候
John
点网工作 <做*** @ hotmail.com>在消息中写道
news:77 ************************** @ posting.google.c om ...
我读了许多关于禁用提交按钮的帖子,但是我无法得到这些答案来解决我的问题。我有一个服务器端的asp.net按钮,在按钮后面我有代码
后面做一些简单的处理,然后是
response.redirect。
处理后面的代码,然后是response.redirect
我尝试做的事情之一是放入客户端javascript
来禁用按钮,但这有效果停止所有代码运行服务器按钮单击事件处理程序。
任何人都可以解决这个困境吗?
TIA,dnw。
您好。
结果非常有趣!
如果asp按钮没有服务器端事件点击处理程序,那么你的
建议效果很好!
如果asp按钮有一个服务器端事件点击处理程序,即使有这个处理程序中的
绝对没有代码,你的建议也不会隐藏
div(后来没有隐藏按钮。)
不幸的是,我需要在asp按钮内部处理代码点击
处理程序!
-dnw。
***通过开发人员指南 ***
不要只是参加USENET ......获得奖励!
我已经设法找到了解决方案,虽然它不是一个干净且优雅的
。
有一个asp.net按键和一个HTML按钮
在代码页面后面的init处理程序:
aspnetbutton.Attributes.Add(" onClick"," javascript :func();")
在HTML部分内:
对于html按钮,请设置它的风格属性:
可见性:隐藏;禁用类型="按钮"
对于名为func()的javascript函数:
函数func()
{
document.getElementById(''aspnetbutton'')。style.visi bility =''hidden'';
document.getElementById(''html button' ')。style.visibility =''visible'';
}
基本上,当用户点击asp.net按钮时,客户端
函数被调用,它隐藏了aspnet按钮,并使html
禁用按钮可见。
诀窍是将隐藏的html按钮放在完全相同的
位置作为可见的asp.net按钮,以便它们在设计上重叠
时间。
实际上,我不知道为什么我现在很难隐藏DIV,如果我
可以成功隐藏一个asp.net按钮。
-dnw。
***通过Developersdex发送 ***
不要只是参加USENET ......获得奖励!
Hello.
I''ve read many posts about disabling submit buttons, but I can''t get
these answers to solve my problem.
I have a server side asp.net button, and under the button I have code
behind that does some simple processing, followed by a
response.redirect.
When the user clicks on this button, I would like the button to
instantly appear to be "ghosted / grayed out / disabled", like a
typical disabled button, then carry on and do the code behind
processing, followed by the response.redirect
One of the things I tried doing was putting in client side javascript
to disable the button, but that had the effect of stopping all code
running inside the server button click event handler.
Can anyone solve this dilemna please?
TIA, dnw.
--
Regards
John
"Dot net work" <do***@hotmail.com> wrote in message
news:77**************************@posting.google.c om... Hello.
I''ve read many posts about disabling submit buttons, but I can''t get
these answers to solve my problem.
I have a server side asp.net button, and under the button I have code
behind that does some simple processing, followed by a
response.redirect.
When the user clicks on this button, I would like the button to
instantly appear to be "ghosted / grayed out / disabled", like a
typical disabled button, then carry on and do the code behind
processing, followed by the response.redirect
One of the things I tried doing was putting in client side javascript
to disable the button, but that had the effect of stopping all code
running inside the server button click event handler.
Can anyone solve this dilemna please?
TIA, dnw.
Hello.
The result is very interesting!
If the asp button has no server side event click handler, then your
suggestion works great!
If the asp button has a server side event click handler, even if there
is absolutely no code inside this handler, your suggestion does not hide
the div (and subsequently does not hide the button.)
Unforunately, I need code behind processing inside the asp button click
handler!
-dnw.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!
I have managed to find a solution, although it is not a clean and
elegant one.
Have an asp.net button and an html button
Inside the code behind page init handler:
aspnetbutton.Attributes.Add("onClick", "javascript: func();")
Inside the HTML section:
For the html button, set it''s style property:
VISIBILITY: hidden; disabled type="button"
For the javascript function called func():
function func()
{
document.getElementById(''aspnetbutton'').style.visi bility=''hidden'';
document.getElementById(''html button'').style.visibility=''visible'';
}
Basically, when the user clicks on the asp.net button, the client side
function gets called, and it hides the aspnetbutton, and makes the html
disabled button visible.
The trick is to position the hidden html button in exactly the same
place as the visible asp.net button, so that they overlap at design
time.
Actually, I''m not sure why I had difficulty in hiding the DIV now, if I
can successfully hide an asp.net button.
-dnw.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!
这篇关于立即禁用服务器端asp.net按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!