OnClientClick

hey guys i have an asp button and two click method

OnClientClick
OnClick

i want to excute the OnClick first than OnClientClick but i do not know how to?

<asp:Button ID="btnAdd" runat="server" CssClass="button" Text="Add" ValidationGroup="a"
                            Width="90px" OnClick="btnAdd_Click"  />

see i have valiadators in my web page and when i click the button it goes into the OnClientClick method which is wrong.

it for to valiadate the page then move to OnClientClick method.

please help?
JCWEBHOSTAsked:
Who is Participating?
 
rajapandian_81Commented:
Hi,

If you want to call some javascript function after the event btnAdd_Click, add below code in last line of btnAdd_Click event.

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "spt", "<script type=\"text/javascript\"> JScriptFunctionName(); </script>");

Open in new window

0
 
Ivo StoykovCommented:
you cannot because first into events chain comes ClientClick...

HTH

Ivo Stoykov
0
 
JCWEBHOSTAuthor Commented:
protected void btnAdd_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "OnClientClick", "mainScreen.ShowConfirm(this,'Please confirm','Are you sure to add customers details?');", true);

        txtcellnumber.Text = "########";
    }

Open in new window


Guys this works and my javascript fires, how do i check if the uses click yes or no?

its hard to explain this, that onclick method display a message using ModalPopupExtender with a yes and no button.

my question is that my code on the above excutes

txtcellnumber.Text = "########";

before the user select yes or no.

if they a way that ScriptManager return a value to see if the user selects the yes button
0
 
JCWEBHOSTAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.