Click here to Skip to main content
15,906,173 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I'm trying to execute a SP on the button click which also has OnClientClick through which a javascript is triggered. The problem is OnClientClick works properly but OnClick event doesn't get fire at all kindly help.

Javascript
JavaScript
function Redirect_Final()
{
    display_inner_dropdown(false);
    var Qstring,tid,bid,beid,bdid,r;
    var content;
    document.form1.method="post";
    document.form1.action="Report_Card.aspx";
    content = calculate();
    content += '<br><table align=center cellpadding=1>'
    content += '<tr><td colspan=2 align=left style="color: #FFFFFF; font-family: Arial; font-size: 8pt" bgcolor="#FF0000"><input type=checkbox id=ichk onclick=on_off();> <b>I Accept the above Information.</b> </td></tr>'
    content += '<tr>'
    content += '<td><input id=ibtnsubmit type=button class=mybutton disabled value="Final Submit" onclick=submitMe();></td>'
    content += '<td><input type=button class=mybutton value=Cancel onclick=No_submit();></td>'
    content += '</tr></table>'
    showDialog('Confirmation',content,Global);
}


function submitMe() {

    xmlHttp=ajaxOperation()
    username = document.getElementById("hidusername").value;
    testid = document.getElementById("hidtestid").value;
    str = target + "?type=0&U=" + username + "&T=" + testid;
    sendPage(xmlHttp,str);
    //document.form1.action = "Report_Card.aspx?U=" + username + "&T=" + testid;
    document.form1.submit();
}
function No_submit()
{
    display_inner_dropdown(true)
    hideDialog();
}



ASPX code for button

ASP.NET
<td style="height: 50px; text-align: right">
                                            <asp:Button ID="btn_Submit" OnClientClick="if (!Redirect_Final()) {return false;}" Text=""
                                                runat="server" CssClass="finishnormal" UseSubmitBehavior="False" Height="30px"
                                                Width="94px" onmouseover="this.className='finishhover'" onmouseout="this.className='finishnormal'"
                                                Style="left: 0px" OnClick="btn_Submit_Click" />
                                              
                                        </td>


CS Code

C#
protected void Load_End_Timer()
{
    sql = "sp_EndTime_New_LMS_Test '" + hidusername.Value + "'," + hidtestid.Value;
    DBCon.Simple_InsUpdDel(sql, 3);
}

protected void btn_Submit_Click(object sender, EventArgs e)
{
    Load_End_Timer();
}
Posted
v2
Comments
What the OnClientClick event Redirect_Final() returns?
Member 10434230 16-Dec-13 2:07am    
Can you remove the OnClientClick and check whether btn_Submit_Click is getting called?

1 solution

hi dear,
i think u should put ur button control inside update panel then it will work fine bcz onclient click event fires client side while onclick event is a server side event. may be ur javascript method that is being called during onclient click cause of postback.....

try it out....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900