Javascript在服务器端不起作用 [英] Javascript not working in server side

查看:67
本文介绍了Javascript在服务器端不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai确认消息在我的项目中不起作用.问题是我正在使用javascript函数来验证控件并在单击按钮即Onclientclick()事件时对其进行调用.再次在服务器端,我正在调用确认JavaScript到同一按钮.如下图所示

Hai confirm message is not working in my project. The Problem is i am using javascript function to validate the controls and calling it on click of button i.e Onclientclick() event. Again in server side i am calling confirm javascript to same button. Like below

btnClick.Attributes.Add("onclick", "if(confirm(''Do u like to Continue?'')) { document.getElementById(''hdnTxt'').value=1 } else { document.getElementById(''hdnTxt'').value=0;}");



在aspx页面中,我这样调用



in aspx page i am calling like this

<asp:ImageButton runat="server" ID="btnSave" ImageUrl="~/Images/16_L_save.gif" OnClientClick="return ShowConfirmation();" Height="15px" Width="15px" ToolTip="Save"  OnClick="btnClick_Click">



现在,如果我删除OnClientClick ="return ShowConfirmation();",确认框就不会出现.在按钮事件中,它工作正常.但是我需要两个人同时工作

我该如何解决这个问题



now confirm box is not coming,if i remove OnClientClick="return ShowConfirmation();" in button event, it works fine. But i need both to work @ same time

How can i solve this problem

推荐答案

但是我需要两个都同时工作
一次只能工作一个.在内部,在渲染这两个结果时都将导致客户端onclick事件.因此,一个优先于其他.

如果要在两者中编写执行,则仅保留其中一个并在其中附加操作.喜欢:
But i need both to work @ same time
Only one can work at a time. Internally, at the time of rendering both results in client side onclick event. Thus, one overrides other.

If you want execution written in both, then keep only one and append the operation in it. Like:
OnClientClick="if(confirm(''Do u like to Continue?'')) { document.getElementById(''hdnTxt'').value=1 } else { document.getElementById(''hdnTxt'').value=0;}; return ShowConfirmation();"


这篇关于Javascript在服务器端不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆