我们如何在按钮的onclientclick事件中调用两个javascript函数 [英] how can we will call two javascript functions in onclientclick event in button
问题描述
您好,
我有一个gridview.关于这一点,我在gridview中有一个复选框.我在gridview之外还有一个按钮可以删除特定的选定行.我写了一些JavaScript函数来检查gridview中的复选框,并在onclient click事件中调用该函数.现在,我必须在删除该特定行之前显示确认消息.为此,我也在javascript中编写了一些构型函数.我如何在一个onclient click事件中调用这两个函数.
这是我的代码
Hi frnds,
I have a gridview. on that i have a checkbox in gridview. and i have one more button outside of gridview to delete particular selected row. I wrote some javascript function for checking the checkbox in gridview and iam calling that in onclient click event. Now i have to show confirmation message before deleting that particular row. for that one also i wrote some conformation function in javascript. how can i will call these two functions in one onclient click event.
Here is my code
function TestCheckBox()
{
TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
if(TargetBaseControl == null) return false;
//get target child control.
var TargetChildControl = "CheckBox1";
//get all the control of the type INPUT in the base control.
var Inputs = TargetBaseControl.getElementsByTagName("input");
var c=0;
for(var n = 0; n < Inputs.length; n++)
{
if(Inputs[n].type == 'checkbox' &&
Inputs[n].id.indexOf(TargetChildControl,0) >= 0 &&
Inputs[n].checked)
{
c++;
// return true;
}
}
if(c==1)
{
return true;
}
else if(c>1)
{
for(var j=0;j<Inputs.length;j++)
{
Inputs[j].checked=false;
}
alert('Please select only one transaction');
return false;
}
else if(c==0)
{
alert('Please select One transaction!');
return false;
}
}
another function is
function confirmdelete()
{
if(confirm("Are u sure delete partyhall")==true)
return true;
else
return false;
}
我的按钮代码是
And my button code is
<asp:Button ID="deletebtn" runat="server" Text="Delete Partyhall" BackColor="#0099FF" Font-Bold="true" Font-Size="10pt" ForeColor="White"
OnClientClick="javascript:return TestCheckBox();" onclick="deletebtn_Click" />
推荐答案
我不确定您可以尝试此方法
I am not sure you can try this
OnClientClick="javascript:return TestCheckBox();javascript:return confirmdelete()"
这篇关于我们如何在按钮的onclientclick事件中调用两个javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!