asp:button的OnClientClick事件 [英] OnClientClick event of asp:button

查看:96
本文介绍了asp:button的OnClientClick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的代码有问题.我无法调用此onclient事件:

Hi everyone,

There is something wrong with my code. I am not able to call this onclient event:

function filterSearch()
{
  var combo = $find('<%=RadComboBox1.ClientID %>');
  var comboValue = document.getElementById(combo.UniqueID + "_value").value;
  if (comboValue == null) 
  {
    alert("You must select a category before processing search!");
    return false;
  }
}





<asp:Button ID="btnSearch" runat="server" Style="float: left; color: black; font-weight: bold" Text="Search" OnClick="btnSearch_Click" OnClientClick="javascript: return filterSearch();" />


如果组合框中未选择任何值,则我希望它在按钮的OnClientClick事件处理程序中运行.可能是什么问题?

谢谢,
Amit


I want this to run in the OnClientClick event handler of the button, if no value is selected in combobox. What could be the problem?

Thanks,
Amit

推荐答案

find(' <%= RadComboBox1 .ClientID%>'); var comboValue = document.getElementById(combo.UniqueID + " ).如果(comboValue == ) { alert(" ); 返回 ; } }
find('<%=RadComboBox1.ClientID %>'); var comboValue = document.getElementById(combo.UniqueID + "_value").value; if (comboValue == null) { alert("You must select a category before processing search!"); return false; } }





<asp:Button ID="btnSearch" runat="server" Style="float: left; color: black; font-weight: bold" Text="Search" OnClick="btnSearch_Click" OnClientClick="javascript: return filterSearch();" />


如果组合框中未选择任何值,则我希望它在按钮的OnClientClick事件处理程序中运行.可能是什么问题?

谢谢,
Amit


I want this to run in the OnClientClick event handler of the button, if no value is selected in combobox. What could be the problem?

Thanks,
Amit


您的JavaScript函数未返回真实值.因此,onClick事件将永远不会激活.在OnClientClick中返回true后,会发生onClick事件.
喜欢
Your javascript function does not return true value. So, onClick event will never active. after returning true in OnClientClick, onClick event occur.
Like
function filterSearch()
{
  var combo =


find(''<%=RadComboBox1.ClientID %>''); var comboValue = document.getElementById(combo.UniqueID + "_value").value; if (comboValue == null) { alert("You must select a category before processing search!"); return false; } return true; }
find(''<%=RadComboBox1.ClientID %>''); var comboValue = document.getElementById(combo.UniqueID + "_value").value; if (comboValue == null) { alert("You must select a category before processing search!"); return false; } return true; }


<asp:button id="btnSearch" runat="server" style="float: left; color: black; font-weight: bold" text="Search" onclick="btnSearch_Click" onclientclick="return filterSearch()==true?true:false;" xmlns:asp="#unknown" />


这篇关于asp:button的OnClientClick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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