删除按钮问题
我在 ASP.NET 应用程序中使用一个链接按钮来进行删除。为了进行确认,我添加了 OnClientclick="return ValidateOnDelete();"
属性。默认情况下它工作得很好。但我有一个条件是,当用户不是管理员时,删除按钮将被禁用。我的问题是,如果用户在禁用模式下单击删除按钮,则会出现确认消息。如何才能避免这个问题呢?
I am using one link button in an asp.net application for delete purpose. For the confirmation i added the property of OnClientclick="return ValidateOnDelete();"
. By Default it works as fine. But i have One condition is that When the user is not admin, the delete button will be disabled. My problem is that, if the user clicks on the delete button when it is in disabled mode, the confirmation message will come. How it can avoid this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将按钮传递给 ValidateOnDelete() 函数,
然后在 ValidateOnDelete() 函数中对按钮禁用状态进行测试
pass the button to the ValidateOnDelete() function using
then within the ValidateOnDelete() function do a test for the button disabled status
您可以在页面加载时添加 javascript
IE
Page.ClientScript.RegisterStartupScript(typeof({The Wep Page Namespace}), "{Your FunctionName}", "javascript text here", true)
或者创建并隐藏带有标志的文本框
IE。
然后在页面加载期间,如果是管理员用户,则将其设置为 1
然后在 javascript 中引用此框
或在页面加载时添加该属性
IE
Button1.attributes.add["OnClientclick] = "return ValidateOnDelete();"
Sp
You could add the javascript on page load
i.e
Page.ClientScript.RegisterStartupScript(typeof({The Wep Page Namespace}), "{Your FunctionName}", "javascript text here", true)
Or create and hidden textbox with a flag
Ie.
And then during the page load set this to 1 if its an admin users
Then refer to this box in your javascript
or add the attribute at page load
i.e
Button1.attributes.add["OnClientclick] = "return ValidateOnDelete();"
Sp